PHPackages                             timmylindh/laravel-beanstalk-worker - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Queues &amp; Workers](/categories/queues)
4. /
5. timmylindh/laravel-beanstalk-worker

ActiveLibrary[Queues &amp; Workers](/categories/queues)

timmylindh/laravel-beanstalk-worker
===================================

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

v1.2.0(1mo ago)32.9kMITPHPPHP ^8.2||^8.3||^8.4CI passing

Since Apr 27Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/timmylindh/laravel-beanstalk-worker)[ Packagist](https://packagist.org/packages/timmylindh/laravel-beanstalk-worker)[ Docs](https://github.com/timmylindh/laravel-beanstalk-worker)[ GitHub Sponsors]()[ RSS](/packages/timmylindh-laravel-beanstalk-worker/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (6)Dependencies (20)Versions (8)Used By (0)

laravel-beanstalk-worker
========================

[](#laravel-beanstalk-worker)

[![Latest Version on Packagist](https://camo.githubusercontent.com/44c1b0ed78884bbcb3348994a9099e113fe4086ca9688b4a7f4a92c790215d04/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74696d6d796c696e64682f6c61726176656c2d6265616e7374616c6b2d776f726b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timmylindh/laravel-beanstalk-worker)[![GitHub Tests Action Status](https://camo.githubusercontent.com/7a101f66ffbf8422837b11f29e56d9d230b552b974d0e0fbb991f313f0570c18/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74696d6d796c696e64682f6c61726176656c2d6265616e7374616c6b2d776f726b65722f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/timmylindh/laravel-beanstalk-worker/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/615a2d59750fba6958157b4e4947de5b27c2ed8061a7ca57b8267ec261ac223c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f74696d6d796c696e64682f6c61726176656c2d6265616e7374616c6b2d776f726b65722f636865636b2d636f64652d666f726d617474696e672e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/timmylindh/laravel-beanstalk-worker/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/02133b48829351f35599a1e8e451814b9b4ee554fef3c953399b3716803861bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74696d6d796c696e64682f6c61726176656c2d6265616e7374616c6b2d776f726b65722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/timmylindh/laravel-beanstalk-worker)

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
------------

[](#installation)

Requirements:

- Laravel &gt;= 10
- PHP &gt;= 8.2

Install the package:

```
composer require timmylindh/laravel-beanstalk-worker
```

Publish config (optional):

```
php artisan vendor:publish --tag="laravel-beanstalk-worker-config"
```

Publish EB deploy hooks (Amazon Linux 2023):

```
php artisan vendor:publish --tag="laravel-beanstalk-worker-deploy"
chmod +x .platform/hooks/postdeploy/*.sh
```

Automatic setup
---------------

[](#automatic-setup)

Recommended. Set `WORKER_TIMEOUT` and let the hooks align all timeouts automatically.

1. In Elastic Beanstalk (Worker env), set environment variables:

- `IS_WORKER=true`
- `WORKER_TIMEOUT= (e.g., 300, 900, 1000)`
- `SQS_QUEUE_URL=https://sqs..amazonaws.com//` (\*optional)

2. Set Worker HTTP path to `/worker/queue` (Configuration → Worker → HTTP path).

Hooks automatically configured from WORKER\_TIMEOUT:

- PHP: `max_execution_time = WORKER_TIMEOUT`
- PHP‑FPM: `request_terminate_timeout = WORKER_TIMEOUT`
- Nginx: `fastcgi_read_timeout = WORKER_TIMEOUT + 30s`
- SQS: VisibilityTimeout to `WORKER_TIMEOUT + 100s`
- SQSD: `Visibility Timeout = WORKER_TIMEOUT + 100s`
- SQSD: `Inactivity Timeout = WORKER_TIMEOUT + 30s`

Note that when using the automatic setup, some values that are set through the Elastic Benstalk dashboard will be overwritten on deployment.

\*optional: If the `SQS_QUEUE_URL` is not provided the `VisibilityTimeout` will have to be set manually on the SQS queue.

### Cron (optional)

[](#cron-optional)

Add a periodic task that runs `php artisan schedule:run` via the worker:

1. Create `cron.yaml` in your app root:

```
version: 1
cron:
    - name: "cron"
      url: "/worker/cron"
      schedule: "* * * * *"
```

2. Ensure `IS_WORKER=true`. The package exposes `/worker/cron` and will run your Laravel scheduler.

Manual setup
------------

[](#manual-setup)

Use only if you don’t publish the hooks. Configure to avoid premature redeliveries:

- Set Worker HTTP path to `/worker/queue`.
- Set env `IS_WORKER=true`.
- SQS `VisibilityTimeout = WORKER_TIMEOUT + ~100s`
- SQSD `VisibilityTimeout = WORKER_TIMEOUT + ~100s`
- SQSD `InactivityTimeout = WORKER_TIMEOUT + ~30s`
- Nginx `fastcgi_read_timeout = WORKER_TIMEOUT + ~30s`
- PHP‑FPM `request_terminate_timeout = WORKER_TIMEOUT`
- PHP `max_execution_time = WORKER_TIMEOUT`

Configuration
-------------

[](#configuration)

`config/worker.php` (publish to customize):

```
return [
    /*
     * Whether the application is a worker or not.
     * This will determine whether to register the worker routes or not.
     */
    "is_worker" => env("IS_WORKER", false),

    // The number of seconds to wait before retrying a job that encountered an uncaught exception.
    "backoff" => env("WORKER_BACKOFF", 0),

    // The number of seconds a job may run before timing out.
    "timeout" => env("WORKER_TIMEOUT", 60),

    // The maximum number of times a job may be attempted.
    "max_tries" => env("WORKER_MAX_TRIES", 1),
];
```

Jobs can still set `$timeout` and `$tries`. Ensure `$timeout
