dereuromark / cakephp-queue
The Queue plugin for CakePHP provides deferred task execution.
Installs: 649 312
Dependents: 13
Suggesters: 1
Security: 0
Stars: 307
Watchers: 22
Forks: 137
Open Issues: 2
Type:cakephp-plugin
Requires
- php: >=8.1
- brick/varexporter: ^0.4.0 || ^0.5.0
- cakephp/cakephp: ^5.0.0
Requires (Dev)
- cakedc/cakephp-phpstan: ^3.0.0
- cakephp/bake: ^3.0.1
- cakephp/migrations: ^4.0.1
- dereuromark/cakephp-dto: ^2.1.0
- dereuromark/cakephp-ide-helper: ^2.0.0
- dereuromark/cakephp-templating: ^0.2.1
- dereuromark/cakephp-tools: ^3.0.0
- fig-r/psr2r-sniffer: dev-master
- friendsofcake/search: ^7.0.0
- phpunit/phpunit: ^10.1
Suggests
- dereuromark/cakephp-ide-helper: For maximum IDE support, especially around createJob() usage.
- dereuromark/cakephp-tools: For the QueueEmailTask (if you don't write your own task here). Also for admin backend.
- friendsofcake/search: For admin backend and filtering of current jobs.
- dev-master
- 8.2.0
- 8.1.1
- 8.1.0
- 8.0.0
- 8.0.0-RC
- 7.2.3
- 7.2.2
- 7.2.1
- 7.2.0
- 7.1.3
- 7.1.2
- 7.1.1
- 7.1.0
- 7.0.1
- 7.0.0
- 7.0.0-RC
- 6.9.1
- 6.9.0
- 6.8.0
- 6.7.2
- 6.7.1
- 6.7.0
- 6.6.2
- 6.6.1
- 6.6.0
- 6.5.0
- 6.4.4
- 6.4.3
- 6.4.2
- 6.4.1
- 6.4.0
- 6.3.2
- 6.3.1
- 6.3.0
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.0
- 6.0.2
- 6.0.1
- 6.0.0
- 6.0.0-beta
- 6.0.0-alpha
- 5.4.0
- 5.3.0
- 5.2.1
- 5.2.0
- 5.1.0
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 5.0.0-rc
- 5.0.0-beta
- 4.4.1
- 4.4.0
- 4.3.1
- 4.3.0
- 4.2.3
- 4.2.2
- 4.2.1
- 4.2.0
- 4.1.1
- 4.1.0
- 4.0.1
- 4.0.0
- 4.0.0-RC
- 3.16.2
- 3.16.1
- 3.16.0
- 3.15.1
- 3.15.0
- 3.14.1
- 3.14.0
- 3.13.1
- 3.13.0
- 3.12.0
- 3.11.0
- 3.10.4
- 3.10.3
- 3.10.2
- 3.10.1
- 3.10.0
- 3.9.0
- 3.8.1
- 3.8.0
- 3.7.1
- 3.7.0
- 3.6.3
- 3.6.2
- 3.6.1
- 3.6.0
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.1
- 3.4.0
- 3.3.2
- 3.3.0
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.0
- 2.3.0
- 2.2.0
- 2.1.0
- 2.0.0
- dev-cake4
- dev-cake5-7.x
- dev-cake2
- dev-cake3
This package is auto-updated.
Last update: 2024-11-19 21:57:24 UTC
README
This branch is for use with CakePHP 5.0+. For details see version map.
Background
This is a very simple and minimalistic job queue (or deferred-task) system for CakePHP. If you need a very basic PHP internal queue tool, this is definitely an option. It is also a great tool for demo purposes on how queues work and doesn't have any dependencies.
Overall functionality is inspired by systems like Gearman, Beanstalk or dropr, but without any illusion to compete with these more advanced Systems.
The plugin is an attempt to provide a basic, simple to use method to enable deferred job execution, without the hassle of setting up or running an extra queue daemon, while integrating nicely into CakePHP and also simplifying the creation of worker scripts. You can also easily provide progress and status information into your pages.
Please also read my blog posts about deferred execution and real-life example usage [new]. For more high-volume and sophisticated use cases please see the awesome list alternatives.
Why use deferred execution?
Deferred execution makes sense (especially in PHP) when your page wants to execute tasks, which are not directly related to rendering the current page. For instance, in a BBS-type system, a new users post might require the creation of multiple personalized email messages, notifying other users of the new content. Creating and sending these emails is completely irrelevant to the currently active user, and should not increase page response time. Another example would be downloading, extraction and/or analyzing an external file per request of the user. The regular solution to these problems would be to create specialized cronjobs which use specific database states to determine which action should be done.
The Queue plugin provides a simple method to create and run such non-user-interaction-critical tasks.
Another important reason is that specific jobs can be (auto)retried if they failed. So if the email server didn't work the first time, or the API gateway had an issue, the current job to be executed isn't lost but kept for rerun. Most of those external services should be treated as failable once every x calls, and as such a queue implementation can help reducing issues due to such failures. If a job still can't finish despite retries, you still have the option to debug its payload and why this job cannot complete. No data is lost here.
While you can run multiple workers, and can (to some extent) spread these workers to different machines via a shared database, you should consider using a more advanced system for high volume/high number of workers systems.
Demo
See Sandbox app.
Installation and Usage
See Documentation.
Cronjob based background scheduling
If you are looking for scheduling certain background jobs: This plugin works flawlessly with QueueScheduler plugin.