Akismet for Laravel 6.x/7.x/8.x

Overview

Laravel Akismet

Build Status Total Downloads Latest Stable Version MIT Licensed

Installation

Install this package with composer:

composer require nickurt/laravel-akismet

Copy the config files for the api

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)

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

// 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.

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

IsSpam Event

This event will be fired when the request contains spam nickurt\Akismet\Events\IsSpam

ReportSpam Event

This event will be fired when you succesfully reported spam nickurt\Akismet\Events\ReportSpam

ReportHam Event

This event will be fired when you succesfully reported ham nickurt\Akismet\Events\ReportHam

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

Comments
  • Null values issue

    Null values issue

    I've just been debugging an issue for a while before realizing that it's submitting blog as null and erroring with:

    "Missing required field: blog."

    All of the values that are being submitted as null should be empty strings otherwise akismet won't process the request.

    opened by garygreen 8
  • Resolving through IOC

    Resolving through IOC

    If you dependency inject the class it won't set the API details because it's not binding the full namespace: https://github.com/nickurt/laravel-akismet/blob/master/src/ServiceProvider.php#L24

    The above should be an alias.

    opened by garygreen 4
  • Dependencies errors when trying to install

    Dependencies errors when trying to install

    Greetings, I'm getting these composer errors when trying to install on Laravel 5.2

    Problem 1 - Installation request for nickurt/laravel-akismet ^0.0.1 -> satisfiable by nickurt/laravel-akismet[0.0.1]. - Conclusion: remove guzzlehttp/guzzle 6.1.1

    - Conclusion: don't install guzzlehttp/guzzle 6.1.1
    - nickurt/laravel-akismet 0.0.1 requires guzzlehttp/guzzle 5.* -> satisfiable by guzzlehttp/guzzle[5.0.0, 5.0.1, 5.0.2, 5.0.3, 5.1.0,
    

    5.2.0, 5.3.0]. - Can only install one of: guzzlehttp/guzzle[5.0.0, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.0.1, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.0.2, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.0.3, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.1.0, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.2.0, 6.1.1]. - Can only install one of: guzzlehttp/guzzle[5.3.0, 6.1.1]. - Installation request for guzzlehttp/guzzle == 6.1.1.0 -> satisfiable by guzzlehttp/guzzle[6.1.1].

    opened by newelement 3
  • Update orchestra/testbench requirement from ^4.0|^5.0 to ^6.0.0

    Update orchestra/testbench requirement from ^4.0|^5.0 to ^6.0.0

    ⚠️ Dependabot is rebasing this PR ⚠️

    If you make any changes to it yourself then they will take precedence over the rebase.


    Updates the requirements on orchestra/testbench to permit the latest version.

    Release notes

    Sourced from orchestra/testbench's releases.

    v6.0.0

    Added

    • Added Orchestra\Testbench\Factories\UserFactory to handle Illuminate\Foundation\Auth\User model.
    • Automatically autoloads Illuminate\Database\Eloquent\LegacyFactoryServiceProvider if the service provider exists.

    Changes

    • Update support for Laravel Framework v8.
    • Increase minimum PHP version to 7.3 and above (tested with 7.3 and 7.4).
    • Configuration changes:
      • Changed auth.providers.users.model to Illuminate\Foundation\Auth\User.
      • Changed queue.failed.driver to database-uuid.
    Changelog

    Sourced from orchestra/testbench's changelog.

    6.0.0

    Released: 2020-09-08

    Added

    • Added Orchestra\Testbench\Factories\UserFactory to handle Illuminate\Foundation\Auth\User model.
    • Automatically autoloads Illuminate\Database\Eloquent\LegacyFactoryServiceProvider if the service provider exists.

    Changes

    • Update support for Laravel Framework v8.
    • Increase minimum PHP version to 7.3 and above (tested with 7.3 and 7.4).
    • Configuration changes:
      • Changed auth.providers.users.model to Illuminate\Foundation\Auth\User.
      • Changed queue.failed.driver to database-uuid.
    Commits

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Note: This repo was added to Dependabot recently, so you'll receive a maximum of 5 PRs for your first few update runs. Once an update run creates fewer than 5 PRs we'll remove that limit.

    You can always request more updates by clicking Bump now in your Dependabot dashboard.

    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language
    • @dependabot badge me will comment on this PR with code to add a "Dependabot enabled" badge to your readme

    Additionally, you can set the following in your Dependabot dashboard:

    • Update frequency (including time of day and day of week)
    • Pull request limits (per update run and/or open at any time)
    • Out-of-range updates (receive only lockfile updates, if desired)
    • Security updates (receive only security updates, if desired)
    dependencies 
    opened by dependabot-preview[bot] 1
  • Bad PwnedPasswords include

    Bad PwnedPasswords include

    Here https://github.com/nickurt/laravel-akismet/blob/master/src/Akismet.php#L7 you're including a PwnedPasswords package you aren't using in the file and haven't included in your composer.json.

    opened by Flynsarmy 1
  • Refactor getResponseData

    Refactor getResponseData

    I would like to save the data that's submitted to check for the spam report but at the moment it's private function. It would be nice to add a toArray() function which would return an array of data that will be sent to check the spam report.

    opened by garygreen 1
  • Upgrade to GitHub-native Dependabot

    Upgrade to GitHub-native Dependabot

    Dependabot Preview will be shut down on August 3rd, 2021. In order to keep getting Dependabot updates, please merge this PR and migrate to GitHub-native Dependabot before then.

    Dependabot has been fully integrated into GitHub, so you no longer have to install and manage a separate app. This pull request migrates your configuration from Dependabot.com to a config file, using the new syntax. When merged, we'll swap out dependabot-preview (me) for a new dependabot app, and you'll be all set!

    With this change, you'll now use the Dependabot page in GitHub, rather than the Dependabot dashboard, to monitor your version updates, and you'll configure Dependabot through the new config file rather than a UI.

    If you've got any questions or feedback for us, please let us know by creating an issue in the dependabot/dependabot-core repository.

    Learn more about migrating to GitHub-native Dependabot

    Please note that regular @dependabot commands do not work on this pull request.

    dependencies 
    opened by dependabot-preview[bot] 0
  • Throw exception on invalid API call

    Throw exception on invalid API call

    In combination with #6 it would have been useful to get the error straight away by the app throwing an exception, that way can quickly spot/catch invalid API calls to akismet.

    opened by garygreen 0
Owner
Nick
Nick
⚡ Laravel Charts — Build charts using laravel. The laravel adapter for Chartisan.

What is laravel charts? Charts is a Laravel library used to create Charts using Chartisan. Chartisan does already have a PHP adapter. However, this li

Erik C. Forés 31 Dec 18, 2022
Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster.

Laravel Kickstart What is Laravel Kickstart? Laravel Kickstart is a Laravel starter configuration that helps you build Laravel websites faster. It com

Sam Rapaport 46 Oct 1, 2022
Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

Laravel User Activity Log - a package for Laravel 8.x that provides easy to use features to log the activities of the users of your Laravel app

null 9 Dec 14, 2022
Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application.

Laravel Segment Laravel Segment is an opinionated, approach to integrating Segment into your Laravel application. Installation You can install the pac

Octohook 13 May 16, 2022
Laravel Sanctum support for Laravel Lighthouse

Lighthouse Sanctum Add Laravel Sanctum support to Lighthouse Requirements Installation Usage Login Logout Register Email Verification Forgot Password

Daniël de Wit 43 Dec 21, 2022
Bring Laravel 8's cursor pagination to Laravel 6, 7

Laravel Cursor Paginate for laravel 6,7 Installation You can install the package via composer: composer require vanthao03596/laravel-cursor-paginate U

Pham Thao 9 Nov 10, 2022
A package that uses blade templates to control how markdown is converted to HTML inside Laravel, as well as providing support for markdown files to Laravel views.

Install Install via composer. $ composer require olliecodes/laravel-etched-blade Once installed you'll want to publish the config. $ php artisan vendo

Ollie Codes 19 Jul 5, 2021
A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic

A light weight laravel package that facilitates dealing with arabic concepts using a set of classes and methods to make laravel speaks arabic! concepts like , Hijri Dates & Arabic strings and so on ..

Adnane Kadri 49 Jun 22, 2022
Jetstrap is a lightweight laravel 8 package that focuses on the VIEW side of Jetstream / Breeze package installed in your Laravel application

A Laravel 8 package to easily switch TailwindCSS resources generated by Laravel Jetstream and Breeze to Bootstrap 4.

null 686 Dec 28, 2022
Laravel Jetstream is a beautifully designed application scaffolding for Laravel.

Laravel Jetstream is a beautifully designed application scaffolding for Laravel. Jetstream provides the perfect starting point for your next Laravel application and includes login, registration, email verification, two-factor authentication, session management, API support via Laravel Sanctum, and optional team management.

The Laravel Framework 3.5k Jan 8, 2023
Laravel Larex lets you translate your whole Laravel application from a single CSV file.

Laravel Larex Translate Laravel Apps from a CSV File Laravel Larex lets you translate your whole Laravel application from a single CSV file. You can i

Luca Patera 68 Dec 12, 2022
A Laravel package that adds a simple image functionality to any Laravel model

Laraimage A Laravel package that adds a simple image functionality to any Laravel model Introduction Laraimage served four use cases when using images

Hussein Feras 52 Jul 17, 2022
A Laravel extension for using a laravel application on a multi domain setting

Laravel Multi Domain An extension for using Laravel in a multi domain setting Description This package allows a single Laravel installation to work wi

null 658 Jan 6, 2023
Example of using abrouter/abrouter-laravel-bridge in Laravel

ABRouter Laravel Example It's a example of using (ABRouter Laravel Client)[https://github.com/abrouter/abrouter-laravel-bridge] Set up locally First o

ABRouter 1 Oct 14, 2021
Laravel router extension to easily use Laravel's paginator without the query string

?? THIS PACKAGE HAS BEEN ABANDONED ?? We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore.

Spatie 307 Sep 23, 2022
Laravel application project as Sheina Online Store backend to be built with Laravel and VueJS

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Boas Aditya Christian 1 Jan 11, 2022
Postgis extensions for laravel. Aims to make it easy to work with geometries from laravel models.

Laravel Wrapper for PostgreSQL's Geo-Extension Postgis Features Work with geometry classes instead of arrays. $model->myPoint = new Point(1,2); //lat

Max 340 Jan 6, 2023
laravel - Potion is a pure PHP asset manager for Laravel 5 based off of Assetic.

laravel-potion Potion is a pure PHP asset manager for Laravel based off of Assetic. Description Laravel 5 comes with a great asset manager called Elix

Matthew R. Miller 61 Mar 1, 2022
Llum illuminates your Laravel projects speeding up your Github/Laravel development workflow

Llum illuminates your Laravel projects speeding up your Github/Laravel development workflow

Sergi Tur Badenas 110 Dec 25, 2022