Installation:
composer require basecom/akeneo-cron-ui
Ensure CustomEntityBundle is installed (follow Akeneo Labs guide).
Register the Bundle:
Add to config/bundles.php:
return [
\Basecom\Bundle\CronUiBundle\BasecomCronUiBundle::class => ['all' => true],
];
Database Update: Run:
php bin/console doctrine:schema:update --force
First Use Case:
Access the UI at /admin/cronjobs to manage cronjobs via the Akeneo PIM interface.
Extend \Symfony\Component\Console\Command\Command and tag as command.cronjob:
# config/services.yaml
services:
App\Command\MyCronCommand:
tags:
- { name: 'command.cronjob', jobCode: 'my_custom_job' }
* * * * * for every minute).Extend \Akeneo\Tool\Bundle\JobBundle\Model\JobInterface and tag as job.cronjob:
services:
App\Job\MyAkeneoJob:
tags:
- { name: 'job.cronjob', jobCode: 'akeneo_my_job' }
Automatic Registration:
The bundle auto-discovers services tagged with command.cronjob or job.cronjob.
Manual Registration (Advanced):
Use the BasecomCronUiBundle's event listener to register jobs programmatically:
use Basecom\Bundle\CronUiBundle\Event\CronJobRegisterEvent;
public function onCronJobRegister(CronJobRegisterEvent $event) {
$event->addJob(new MyCustomJob());
}
/admin/cronjobs:
0 0 * * * for daily at midnight).Akeneo Version Compatibility:
Database Schema Conflicts:
CustomEntityBundle is misconfigured. Run:
php bin/console doctrine:schema:validate
before updating.Job Code Uniqueness:
jobCode tags will overwrite each other. Validate uniqueness in:
php bin/console debug:container --tag=command.cronjob
Cron Syntax Errors:
* * * * * *) may silently fail. Test with:
php bin/console akeneo:job:run my_job_code
Check Event Dispatching:
CronJobRegisterEvent listeners are active. Add debug logs:
public function onCronJobRegister(CronJobRegisterEvent $event) {
\Log::debug('Registered jobs:', $event->getJobs()->toArray());
}
UI Not Loading:
php bin/console cache:clear
bundles.php.Logs in UI:
akeneo_cron_job_execution table. Query directly:
SELECT * FROM akeneo_cron_job_execution WHERE job_code = 'my_job_code';
Custom Fields:
// src/Entity/CronJobExtension.php
use Basecom\Bundle\CronUiBundle\Entity\CronJob;
class CronJobExtension {
public function load(CronJob $job, array $data) {
$job->setPriority($data['priority'] ?? 0);
}
}
services.yaml:
services:
App\Extension\CronJobExtension:
tags:
- { name: 'basecom_cron_ui.cronjob_extension' }
Custom UI Templates:
templates/basecom_cron_ui/. Example:
templates/
└── basecom_cron_ui/
└── CronJob/
└── index.html.twig # Override the list view
Pre/Post-Execution Hooks:
use Basecom\Bundle\CronUiBundle\Event\CronJobExecutionEvent;
public function onPreExecution(CronJobExecutionEvent $event) {
if ($event->getJob()->getCode() === 'my_job') {
$event->setCancelled(true); // Skip execution
}
}
tags:
- { name: 'kernel.event_listener', event: 'basecom_cron_ui.pre_execution', method: 'onPreExecution' }
How can I help you explore Laravel packages today?