autobus-php/autobus-bus-bundle

AutobusBusBundle

Installs: 199

Dependents: 1

Suggesters: 0

Security: 0

Stars: 1

Watchers: 4

Forks: 4

Open Issues: 0

Type:symfony-bundle

2.3.11 2024-02-06 14:56 UTC

README

A PHP Extensible Service Bus

Configure your atomic jobs in order to be played by cron, queue listener or webservice.

Requirements

  • PHP 8+

Installation

Download the Bundle

composer require autobus-php/autobus-bus-bundle

Download desired queuing bundle

composer require enqueue/gps:0.10.*
composer require enqueue/sqs:0.10.*

Environment variables

Update your .env file to add:

# 'gps:' for Google PubSub / 'sqs:' for AWS SQS 
ENQUEUE_DSN=sqs:

# Only for AWS SQS usage
AWS_REGION=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

Configuration

Topic jobs

2 queuing systems are available:

  • With Google PubSub:

Execute the following command with Supervisor tool:

php bin/console autobus:pubsub:consume
  • With AWS SQS:

    Add the following line to your crontab:

*/5 * * * * php bin/console autobus:sqs:consume

Cron jobs

Add the following line to your crontab:

* * * * * php bin/console autobus:cron:run

Usage

Create a job

To create a new job:

  • Create it's class, implementing Autobus\Bundle\BusBundle\Runner\RunnerInterface ; it may extend Autobus\Bundle\BusBundle\Runner\AbstractRunner
  • Declare it as a service in your bundle's services.yml, with tag bus.runner
  • Create an instance from the web UI