Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Akeneo Cron Ui Laravel Package

basecom/akeneo-cron-ui

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require basecom/akeneo-cron-ui
    

    Ensure CustomEntityBundle is installed (follow Akeneo Labs guide).

  2. Register the Bundle: Add to config/bundles.php:

    return [
        \Basecom\Bundle\CronUiBundle\BasecomCronUiBundle::class => ['all' => true],
    ];
    
  3. Database Update: Run:

    php bin/console doctrine:schema:update --force
    
  4. First Use Case: Access the UI at /admin/cronjobs to manage cronjobs via the Akeneo PIM interface.


Implementation Patterns

Defining Cronjobs in Code

Symfony Commands

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' }
  • Job Code: Unique identifier for the UI.
  • Schedule: Configured via the UI (e.g., * * * * * for every minute).

Akeneo Jobs

Extend \Akeneo\Tool\Bundle\JobBundle\Model\JobInterface and tag as job.cronjob:

services:
    App\Job\MyAkeneoJob:
        tags:
            - { name: 'job.cronjob', jobCode: 'akeneo_my_job' }

Registering Cronjobs

  1. Automatic Registration: The bundle auto-discovers services tagged with command.cronjob or job.cronjob.

  2. 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());
    }
    

UI Workflow

  1. Navigate to /admin/cronjobs:
    • View existing cronjobs, their schedules, and statuses.
    • Enable/disable jobs without code changes.
  2. Create/Edit Jobs:
    • Define schedules (e.g., 0 0 * * * for daily at midnight).
    • Set job codes to link to your Symfony/Akeneo commands.
  3. Logging:
    • View execution logs directly in the UI for debugging.

Gotchas and Tips

Pitfalls

  1. Akeneo Version Compatibility:

    • Tested only on Akeneo 4.0.33+. Avoid using with older versions.
    • If upgrading Akeneo, verify bundle compatibility (last release: 2018).
  2. Database Schema Conflicts:

    • Schema updates may fail if CustomEntityBundle is misconfigured. Run:
      php bin/console doctrine:schema:validate
      
      before updating.
  3. Job Code Uniqueness:

    • Duplicate jobCode tags will overwrite each other. Validate uniqueness in:
      php bin/console debug:container --tag=command.cronjob
      
  4. Cron Syntax Errors:

    • The UI validates cron syntax, but invalid schedules (e.g., * * * * * *) may silently fail. Test with:
      php bin/console akeneo:job:run my_job_code
      

Debugging Tips

  1. Check Event Dispatching:

    • Ensure CronJobRegisterEvent listeners are active. Add debug logs:
      public function onCronJobRegister(CronJobRegisterEvent $event) {
          \Log::debug('Registered jobs:', $event->getJobs()->toArray());
      }
      
  2. UI Not Loading:

    • Clear Akeneo cache:
      php bin/console cache:clear
      
    • Verify the bundle is enabled in bundles.php.
  3. Logs in UI:

    • Execution logs are stored in akeneo_cron_job_execution table. Query directly:
      SELECT * FROM akeneo_cron_job_execution WHERE job_code = 'my_job_code';
      

Extension Points

  1. Custom Fields:

    • Extend the cronjob entity to add metadata (e.g., priority, environment tags):
      // src/Entity/CronJobExtension.php
      use Basecom\Bundle\CronUiBundle\Entity\CronJob;
      
      class CronJobExtension {
          public function load(CronJob $job, array $data) {
              $job->setPriority($data['priority'] ?? 0);
          }
      }
      
    • Register the extension in services.yaml:
      services:
          App\Extension\CronJobExtension:
              tags:
                  - { name: 'basecom_cron_ui.cronjob_extension' }
      
  2. Custom UI Templates:

    • Override the UI templates in templates/basecom_cron_ui/. Example:
      templates/
      └── basecom_cron_ui/
          └── CronJob/
              └── index.html.twig  # Override the list view
      
  3. Pre/Post-Execution Hooks:

    • Subscribe to events:
      use Basecom\Bundle\CronUiBundle\Event\CronJobExecutionEvent;
      
      public function onPreExecution(CronJobExecutionEvent $event) {
          if ($event->getJob()->getCode() === 'my_job') {
              $event->setCancelled(true); // Skip execution
          }
      }
      
    • Tag the listener:
      tags:
          - { name: 'kernel.event_listener', event: 'basecom_cron_ui.pre_execution', method: 'onPreExecution' }
      
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui