2017 © Pedro Peláez
 

library laravel-akismet

Akismet for Laravel 5

image

nickurt/laravel-akismet

Akismet for Laravel 5

  • Thursday, February 15, 2018
  • by nickurt
  • Repository
  • 2 Watchers
  • 32 Stars
  • 6,618 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 8 Forks
  • 0 Open issues
  • 7 Versions
  • 8 % Grown

The README.md

Laravel Akismet

Build Status Total Downloads Latest Stable Version MIT Licensed, (*1)

Installation

Install this package with composer:, (*2)

composer require nickurt/laravel-akismet

Copy the config files for the api, (*3)

php artisan vendor:publish --provider="nickurt\Akismet\ServiceProvider" --tag="config"

Configuration

The Akismet information can be set with environment values in the .env file (or directly in the config/akismet.php file), (*4)

AKISMET_APIKEY=MY_UNIQUE_APIKEY
AKISMET_BLOGURL=https://my-custom-blogurl.dev

Examples

Validation Rule

You can use a hidden-field akismet in your Form-Request to validate if the request is valid, (*5)

// FormRequest ...

public function rules()
{
    return [
        'akismet' => [new \nickurt\Akismet\Rules\AkismetRule(
            request()->input('email'), request()->input('name')
        )]
    ];
}

// Manually ...

$validator = validator()->make(['akismet' => 'akismet'], ['akismet' => [new \nickurt\Akismet\Rules\AkismetRule(
    request()->input('email'), request()->input('name')
)]]);

The AkismetRule requires a email and name parameter to validate the request., (*6)

Events

You can listen to the IsSpam, ReportSpam and ReportHam events, e.g. if you want to log all the IsSpam-requests in your application, (*7)

IsSpam Event

This event will be fired when the request contains spam nickurt\Akismet\Events\IsSpam, (*8)

ReportSpam Event

This event will be fired when you succesfully reported spam nickurt\Akismet\Events\ReportSpam, (*9)

ReportHam Event

This event will be fired when you succesfully reported ham nickurt\Akismet\Events\ReportHam, (*10)

Custom Implementation

Validate Key
if( \Akismet::validateKey() ) {
    // valid
} else {
    // invalid
}
Set CommentAuthor Information
\Akismet::setCommentAuthor("John Doe")
    ->setCommentAuthorUrl("https://www.google.com")
    ->setCommentContent("It's me, John!")
    ->setCommentType('registration');
    // etc

// or
\Akismet::fill([
    'comment_author' => 'John Doe',
    'comment_author_url' => 'https://www.google.com',
    'comment_content' => 'It's me, John!'
]);
// etc
Is it Spam?
if( \Akismet::isSpam() ) {
    // yes, i'm spam!
}
Submit Spam (missed spam)
if( \Akismet::reportSpam() ) {
    // yes, thanks!
}
Submit Ham (false positives)
if( \Akismet::reportHam() ) {
    // yes, thanks!
}

Tests

composer test

The Versions

15/02 2018

dev-master

9999999-dev

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel akismet

12/02 2018

1.3.0

1.3.0.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet

25/07 2017

1.2.0

1.2.0.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet

31/05 2017

1.1.0

1.1.0.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet

23/08 2016

1.0.0

1.0.0.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet

16/04 2016

0.0.2

0.0.2.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet

27/05 2015

0.0.1

0.0.1.0

Akismet for Laravel 5

  Sources   Download

MIT

The Requires

 

laravel akismet