Download the PHP package timmylindh/laravel-beanstalk-worker without Composer

On this page you can find all versions of the php package timmylindh/laravel-beanstalk-worker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-beanstalk-worker

laravel-beanstalk-worker

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Provides functionality to utilize Laravel SQS queues and cron jobs in AWS Elastic Beanstalk worker environments.

The package supports all Laravel queue and cron features, such as retries, backoff, delay, release, max tries, timeout, etc.

Installation

Requires:

You can install the package via composer:

You can publish the config file with:

Usage

Enable worker

Set the environment variable IS_WORKER to enable the worker routes.

Then in the AWS Elastic Beanstalk worker enviroment point the HTTP path to /worker/queue. This will automatically send all SQS messages to the worker.

Enable cron

In your Laravel root project folder add the file cron.yaml with the contents below. This will tell the AWS daemon to publish an SQS cron task message every minute, which will be sent to our worker which will run the scheduled cron jobs.

Configuration

You can publish the config file with:

The configuration contains various properties to control the worker which will run your queued jobs. These are the same as you would provide when running a worker locally using php artisan queue:work.

AWS Elastic Beanstalk

In the AWS Elastic Beanstalk worker there are other options you can set.

Handling timeouts

To handle timeouts properly you should make sure to set the Elastic Beanstalk properties as follows:

Max retries > max(max_retries|$tries, for any job)

Visibility timeout > max(timeout|$timeout, for any job)

Error visibility timeout >= 0: this will control the number of seconds to wait before retrying a timed out job.


Example: If I expect all my jobs to have maximum of 4 retries and a maximum timeout of 250 seconds I will set Max retries = 5 and Visbility timeout = 252.

See configuration section above for more details.

How it works

Normally, in a standard server environment, Laravel queue workers are set up by executing the command php artisan queue:work. However, setting this up in AWS Elastic Beanstalk can be challenging due to the platform's architecture.

Worker Environments in Elastic Beanstalk

Elastic Beanstalk supports worker environments that integrate seamlessly with Amazon SQS. These environments include an SQS daemon that continuously polls the queue, fetching and processing jobs by forwarding them to a specified URL endpoint on your application.

Automatic Message Handling

Challenges

A significant challenge in this setup is the loss of control over the number of maximum attempts for each job and the delay before a job is retried (backoff strategy).

Solution

To address these issues, we utilize a dedicated route /worker/queue which is designed to always return an HTTP 2xx status code, regardless of the job's actual outcome. This ensures that the SQS daemon deletes the job after its first dequeue.

This approach closely mimics the behavior of running a standard Laravel worker using artisan, while integrating into the Elastic Beanstalk environment.

Testing

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of laravel-beanstalk-worker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1||^8.2||^8.3
aws/aws-sdk-php Version ^3.235.5
illuminate/bus Version ^10.0||^11.0
illuminate/contracts Version ^10.0||^11.0
illuminate/http Version ^10.0||^11.0
illuminate/queue Version ^10.0||^11.0
illuminate/support Version ^10.0||^11.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package timmylindh/laravel-beanstalk-worker contains the following files

Loading the files please wait ....