Download the PHP package netglue/zf2-akismet-module without Composer

On this page you can find all versions of the php package netglue/zf2-akismet-module. 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 zf2-akismet-module

ZF2 Akismet Service Module

Abandoned

If you're still using ZF and need this, it's not going anywhere, but it's also not going to receive any maintenance either. Akismet is still useful - you might want to check out gsteel/akismet which is a pretty easy to use standalone client that's well tested… That way you can implement your own validators and just consume the api client!

Intro

A straightforward ZF2 module that provides a service for using the Akismet API and a handy validator you can attach to your form elements.

Current Status

Mostly tested with exception of submitting ham and spam, though there's no reason why these wouldn't work fine as far as I can see.

Install

Install via composer with netglue/zf2-akismet-module then enable in your application.config.php with the module name NetglueAkismet

Add your Akismet ApiKey to local autoloaded config like this:

return array(
    'netglue_akismet' => array(
        'apiKey' => 'YourApiKey',
    ),
);

There are more options to setup defaults. Look at config/module.config.php for a full list.

Akismet Service

The Akismet service, once the module is loaded should be accessible from the main service locator with the name 'NetglueAkismet\Service\AkismetService'. It also has a shorter alias 'AkismetService'

Basic usage of the service goes like this:

$service = $this->getServiceLocator()->get('AkismetService');
$result = $service->isSpam($contentToCheck, $authorEmail, $commentType, $additionalParams);

Not all of the parameters are required and all of them can be passed into the $additionalParams array making sure that the keys match up with whatever is expected by the API. You can find docs for it here: comment-check docs

Validator

The validator is registered through the ValidatorManager by the Module as it depends on a service instance. Providing your form elements are created using the form element manager/factory stuff the validator should be ready to go - this is important. You must be intialising your form with $formElementManager->get('My\Form\Name'); in order for the validator to be properly initialised.

For example, set up your input filter config like this:

public function getInputFilterSpecification() {
    return array(
        'myNameFormElement' => array(
            'required' => true,
            'filters' => array(
                array('name' => 'Zend\Filter\StringTrim'),
            ),
        ),
        'emailFormElement' => array(
            'required' => true,
            'filters' => array(
                array('name' => 'Zend\Filter\StringToLower'),
                array('name' => 'Zend\Filter\StringTrim'),
            ),
        ),
        'comment' => array(
            'required' => true,
            'filters' => array(
                array('name' => 'Zend\Filter\StringTrim'),
            ),
            'validators' => array(
                array(
                    'name' => 'AkismetValidator', // Or 'NetglueAkismet\Validator\Akismet'
                    'options' => array(
                        'comment_type' => 'comment', // Or 'contact-form' or something else, or leave it to the service configured default
                        'context_map' => array(
                            'emailFormElement' => 'comment_author_email',
                            'myNameFormElement' => 'comment_author',
                        ),
                    ),
                ),
            ),
        ),
    );
}

Tests

The tests are pretty good I think, but submitHam and submitSpam aren't tested yet.

To run the tests, CD to the module directory and issue php composer.phar install to download all the dependencies; copy phpunit.xml.dist to phpunit.xml. By default the network tests are disabled. To run those too, comment out or delete the exclude directive in the phpunit.xml and make sure you setup a valid api key in test/config/local.php.


All versions of zf2-akismet-module with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.3
zendframework/zendframework Version ~2.2
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 netglue/zf2-akismet-module contains the following files

Loading the files please wait ...