PHP code example of openclassrooms / akismet-bundle

1. Go to this page and download the library: Download openclassrooms/akismet-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

openclassrooms / akismet-bundle example snippets


// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new OpenClassrooms\Bundle\AkismetBundle\OpenClassroomsAkismetBundle(),
    // ...
);

$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);

$akismet = $container->get('openclassrooms.akismet.services.akismet_service');


$akismet = $container->get('openclassrooms.akismet.services.default_akismet_service');