Download the PHP package omines/akismet without Composer

On this page you can find all versions of the php package omines/akismet. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package akismet

Akismet Client Library for PHP

Latest Stable Version Total Downloads License

This library provides a straightforward object oriented and pluggable implementation of the well known online Akismet spam detection service. All known features and calls are implemented.

Documentation

Install the library with Composer:

Creating the service

You have to bring your own HTTP client implementation, based on Symfony Contracts. Easiest is to install the Symfony HTTP Client component:

When using the Symfony framework this will provide a configurable service you can inject where needed, otherwise you can instantiate a stock client using:

Now instantiate the service class, also providing your Akismet API key and the root URL of your site/blog:

Using as a Symfony service

Add the following to config/services.yaml, assuming autowiring is enabled as it should in Symfony:

Then make sure your relevant .env file or the actual environment variables contain correct values for ROOT_URL and AKISMET_KEY. You can now inject Omines\Akismet\Akismet wherever you need it.

Creating a message

You have to construct and fill an AkismetMessage before you can check or submit anything:

Depending on your framework you will already have some useful data available in either a Symfony HTTP Foundation Request instance or a PSR-7 ServerRequestInterface derivant. Bootstrapping a message from these to copy the user IP, user agent and HTTP referrer fields is easy:

You can, and sometimes should, safely serialize the AkismetMessage class, for example when implementing moderation queues. After moderation you can unserialize the message to submit the exact message you checked before as Ham or Spam.

Checking a message

Performing a spam check is then simple:

Read their blog post on the 'should discard' feature.

Asynchronous invocation

When using symfony/http-client as the HTTP client implementation all calls are asynchronous out of the box. As such, in the example above, the call to Akismet::check is not blocking further execution. This allows you to improve your site performance by continuing to do other tasks in parallel, such as preparing notification emails and such.

Execution will block when you call any informational methods on the response, in this case the isSpam method call.

Submitting confirmed ham and spam

As mentioned before, when implementing moderation you can safely serialize the AkismetMessage instance submitted for checking. After human review you can then help improve Akismet's services by submitting the message as ham or spam:

The MessageResponse object returned by these calls can, if you want, be checked for success with $response->isSuccessful(), in an asynchronous method this is technically not required - the methods are fire and forget.

Usage limit and activity

You can check your usage limits and key/site activity:

For the parameters and response formats of the activity call refer to the Akismet documentation.

Contributing

Contributions are welcome and will be credited.

We accept contributions via Pull Requests on Github. Follow good standards, keep the PHPStan level maxed, and keep the test coverage at 100%.

Before committing, run bin/prepare-commit to automatically follow coding standards, run PHPStan and run all tests. To run the live tests create a .env.local defining AKISMET_KEY. As they run in test mode they will not interfere with your quota or get you banned.

Legal

This software was developed for internal use at Omines Full Service Internetbureau in Eindhoven, the Netherlands. It is shared with the general public under the permissive MIT license, without any guarantee of fitness for any particular purpose. Refer to the included LICENSE file for more details.


All versions of akismet with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
psr/log Version ^3.0
symfony/http-client-contracts Version ^3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package omines/akismet contains the following files

Loading the files please wait ....