Skip to content

HermesBackground jobs for PHP

Emit a message from the request, and let a CLI worker run the slow part. Redis, Predis, RabbitMQ, and Amazon SQS in version 6.x.

What people use it for

The web request emits a message and answers right away. A worker does the slow part.

  • Send emails

    Signup, password reset, or order mails go out from the worker. The request returns before the SMTP server even answers.

  • Invoices and PDFs

    Render the PDF, store it, and attach it to an email in the background. The user clicks once and moves on.

  • Images and video

    Resize uploads, cut thumbnails, or start a transcode. Heavy CPU work stays off the web servers.

  • Data processing

    Recalculate stats, aggregate reports, or clean up records in small messages that several workers share.

  • Imports and exports

    Parse a large CSV or build an export file row by row. Tell the user when it is ready instead of making them wait.

  • Webhooks

    Deliver outgoing webhooks from a worker. RetryTrait tries again with a growing delay when the receiver is down.

  • Third-party APIs

    Sync orders to an ERP, push contacts to a CRM, or call a slow payment API without holding a PHP-FPM process.

  • Notifications

    Fan out push, SMS, or in-app notifications to many users from one emitted message.

  • Search indexing

    Update Elasticsearch, Meilisearch, or a search table after a save, so the write itself stays fast.

  • Cache warming

    Rebuild expensive cache entries after a deploy or a content change, before the next visitor asks for them.

  • Delayed jobs

    Send a reminder in 24 hours or expire a reservation in 15 minutes with executeAt on Redis or Predis.

  • Any slow task

    If it does not have to finish before the response, emit a message and let a handler do it.

See it run ​

A user registers. The web app emits a user.registered message and answers in milliseconds. The worker, a separate CLI process started with php bin/worker.php, takes the message and sends the welcome email. When SMTP times out, RetryTrait sends a copy and the next attempt succeeds.

Where to go next ​

Released under the MIT License.