eschmar / taskchain-bundle
Cronjobs made easy for symfony2.
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.3
- symfony/symfony: ~2.4
This package is auto-updated.
Last update: 2024-10-11 20:16:54 UTC
README
With this bundle you can assign your services to a taskchain, which is executable by console.
Installation
Composer (Packagist):
"require": { "eschmar/taskchain-bundle": "dev-master" },
app/Appkernel.php:
new Eschmar\TaskChainBundle\EschmarTaskChainBundle(),
Usage
The following demo creates a new Task called Test Task
which will simply wait 3 seconds before returning. Your service has to extend the provided abstract class TaskAbstract
.
src/Acme/HelloBundle/Task/TestTask.php:
namespace Acme\HelloBundle\Task; use Eschmar\TaskChainBundle\Task\TaskAbstract; class TestTask extends TaskAbstract { protected function init() { $this->name = 'Test Task'; $this->groups[] = 'test'; } public function execute() { sleep(3); return true; } }
src/Acme/HelloBundle/Resources/config/services.yml:
acme_hello.taskchain_test: class: Acme\HelloBundle\Task\TestTask tags: - { name: taskchain }
Now you can execute the console command:
php app/console taskchain [<group>] [--inset]
The command will execute all tagged services meeting the group requirement. Use the --inset
option to exclude a group but execute all others.
Output:
$ app/console taskchain ______ __ ________ _ /_ __/___ ______/ /__ / ____/ /_ ____ _(_)___ / / / __ `/ ___/ //_/ / / / __ \/ __ `/ / __ \ / / / /_/ (__ ) ,< / /___/ / / / /_/ / / / / / /_/ \__,_/____/_/|_| \____/_/ /_/\__,_/_/_/ /_/ --------------------------- START --------------------------- . Test Task... success ---------------------------- END ----------------------------
License
MIT License