https://github.com/openclassrooms/akismetbundle
https://github.com/openclassrooms/akismetbundle
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/openclassrooms/akismetbundle
- Owner: OpenClassrooms
- License: mit
- Created: 2015-06-10T12:09:01.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2025-03-20T14:15:16.000Z (about 1 year ago)
- Last Synced: 2025-04-11T23:11:43.170Z (about 1 year ago)
- Language: PHP
- Size: 36.1 KB
- Stars: 1
- Watchers: 26
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
AkismetBundle
-------------
[](https://insight.sensiolabs.com/projects/243552ac-5d33-4e9c-b05a-186fc6f507ea)
[](https://travis-ci.org/OpenClassrooms/AkismetBundle)
[](https://coveralls.io/r/OpenClassrooms/AkismetBundle?branch=master)
The AkismetBundle offers integration of the Akismet Library.
Akismet Library is a PHP5 library that provides [Akismet Spam Protection service](https://akismet.com/) functionality in your application.
See [Akismet](https://github.com/OpenClassrooms/Akismet) for full details.
## Installation
This bundle can be installed using composer:
```composer require openclassrooms/akismet-bundle```
or by adding the package to the composer.json file directly:
```json
{
"require": {
"openclassrooms/akismet-bundle": "*"
}
}
```
After the package has been installed, add the bundle to the AppKernel.php file:
```php
// in AppKernel::registerBundles()
$bundles = array(
// ...
new OpenClassrooms\Bundle\AkismetBundle\OpenClassroomsAkismetBundle(),
// ...
);
```
## Configuration
```yml
# app/config/config.yml
openclassrooms_akismet:
key: %akismet.key%
blog: %akismet.blog%
```
## Usage
### Default Service
```php
$commentBuilder = $container->get('openclassrooms.akismet.models.comment_builder');
$akismet = $container->get('openclassrooms.akismet.services.default_akismet_service');
$comment = $commentBuilder->create()
...
->build();
if ($akismet->commentCheck($comment)) {
// store the comment and mark it as spam (in case of a mis-diagnosis).
} else {
// store the comment normally
}
// and
$akismet->submitSpam($comment);
// and
$akismet->submitHam($comment);
```
### Bridge Service
The Bundle integrates a bridge service which gets the Symfony2 requestStack to automatically set the UserIP, UserAgent and Referrer.
```xml
```
You can use it by getting this service id:
```php
$akismet = $container->get('openclassrooms.akismet.services.akismet_service');
```
instead of:
```php
$akismet = $container->get('openclassrooms.akismet.services.default_akismet_service');
```