1. Go to this page and download the library: Download lbonnet/on-page-seo-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/ */
use Lbonnet\OnPageSeoBundle\Message\CheckSeoMessage;use Symfony\Component\Messenger\MessageBusInterface;
// In a controller, command or custom service
public function triggerAudit(MessageBusInterface $bus): void
{
// Uses default configuration values
$bus->dispatch(new CheckSeoMessage());
// Or with custom parameters
$bus->dispatch(new CheckSeoMessage(
startUrl: 'https://example.com/blog',
maxDepth: 2,
excludePatterns: ['#/preview#'],
));
}
namespace App\Scheduler;
use Lbonnet\OnPageSeoBundle\Message\CheckSeoMessage;
use Symfony\Component\Scheduler\Attribute\AsSchedule;
use Symfony\Component\Scheduler\RecurringMessage;
use Symfony\Component\Scheduler\Schedule;
use Symfony\Component\Scheduler\ScheduleProviderInterface;
#[AsSchedule('default')]
final class MainSchedule implements ScheduleProviderInterface
{
public function getSchedule(): Schedule
{
return (new Schedule())
->add(
// Run daily at 03:00 AM
RecurringMessage::cron('0 3 * * *', new CheckSeoMessage())
);
}
}
namespace App\EventListener;
use Lbonnet\OnPageSeoBundle\Event\CrawlCompletedEvent;
use Symfony\Component\EventDispatcher\Attribute\AsEventListener;
use Symfony\Component\Notifier\Notification\Notification;
use Symfony\Component\Notifier\NotifierInterface;
#[AsEventListener]
final class OnPageSeoNotificationListener
{
public function __construct(
private readonly NotifierInterface $notifier,
) {
}
public function __invoke(CrawlCompletedEvent $event): void
{
$report = $event->report;
if (!$report->hasIssues()) {
return;
}
$message = sprintf(
'Found %d SEO issue(s) on %s (audited %d page(s) in %.2fs).',
$report->getIssuesCount(),
$report->startUrl,
$report->totalChecked,
$report->totalDuration
);
$notification = new Notification($message, ['chat/slack', 'email']);
$this->notifier->send($notification);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.