Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 68 | All time: 10,325 This week: 673 |
Version | License | PHP version | Categories | |||
task-bundle 1.0.2 | MIT/X Consortium ... | 5 | PHP 5, Time and Date, Libraries |
Description | Author | ||||||||||||||||||||||
This package can schedule task using cron with Synfony. |
|
Provides a simple framework to manage scheduling and execution of tasks Symfony application.
This bundle requires cron to be installed on the server to be able to execute scheduled tasks
Add the glooby/task-bundle
package to your require
section in the composer.json
file.
$ composer require glooby/task-bundle ~3.0
Add the GloobyTaskBundle to your application's kernel:
<?php
public function registerBundles()
{
$bundles = [
// ...
new Glooby\TaskBundle\GloobyTaskBundle(),
// ...
];
...
}
Create this file /etc/cron.d/glooby_scheduler_run
* nginx cd /path/to/project && php bin/console scheduler:run --env=prod &> /dev/null 2>&1
To setup a new runnable task you should follow these steps
example: src/Glooby/Api/TaskBundle/Task/PingTask.php
class PingTask implements TaskInterface
{
/
* @inheritdoc
*/
public function run(array $params = [])
{
return 'pong';
}
}
Add a service for your task
services:
glooby_task.ping:
class: Glooby\TaskBundle\Task\PingTask
$ bin/console task:run glooby_task.ping
"pong"
To setup a new schedule you should follow the steps below
Follow the steps in Create a executable Task
By tagging your service with the glooby.scheduled_task tag it will be treated as a scheduled task
example:
src/Glooby/Api/TaskBundle/Resources/config/services.yml
services:
glooby_task.ping:
class: Glooby\TaskBundle\Task\PingTask
tags:
- { name: glooby.scheduled_task }
Annotate your class with this annotation: Glooby\TaskBundle\Annotation\Schedule
The first parameter to the annotation is defaulted to the interval parameter. In this parameter you configure the interval that the service should be executed.
The interval is a string of five or optional six subexpressions that describe details of the schedule. The syntax is based on the Linux cron daemon definition.
- - - - - -
| | | | | |
| | | | | + year [optional]
| | | | +----- day of week (0 - 7) (Sunday=0 or 7)
| | | +---------- month (1 - 12)
| | +--------------- day of month (1 - 31)
| +-------------------- hour (0 - 23)
+------------------------- min (0 - 59)
This is the only required parameter
use Glooby\TaskBundle\Annotation\Schedule;
/
@Schedule(" ")
*/
class PingTask implements TaskInterface
{
Here you have several shortcuts that you can use instead for most common use cases
| value | interval | |:---------------:|:------------:| | @yearly | 0 0 1 1 * | | @annually | 0 0 1 1 * | | @monthly | 0 0 1 | | @weekly | 0 0 0 | | @daily | 0 0 * | | @hourly | 0 | | @semi_hourly | /30 * | | @quarter_hourly | /15 * | | | |
use Glooby\TaskBundle\Annotation\Schedule;
/
* @Schedule("@hourly")
*/
class PingTask implements TaskInterface
{
The params that should be used when calling
use Glooby\TaskBundle\Annotation\Schedule;
/
* @Schedule("@weekly", params={"wash": true, "flush": 500})
*/
class CityImporter implements TaskInterface
{
Phe active parameter tells if the schedule should be active or not, default=true
use Glooby\TaskBundle\Annotation\Schedule;
/
@Schedule("/6", active=false)
*/
class PingTask implements TaskInterface
{
bin/console scheduler:run
Install the dependencies:
$ script/bootstrap
Then, run the test suite:
$ script/test
See CONTRIBUTING file.
This bundle is released under the MIT license. See the complete license in the bundle: LICENSE.md
Files (52) |
File | Role | Description | ||
---|---|---|---|---|
bin (2 files) | ||||
script (4 files) | ||||
src (1 file, 12 directories) | ||||
.coveralls.yml | Data | Auxiliary data | ||
.scrutinizer.yml | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONTRIBUTING.md | Data | Auxiliary data | ||
contributors.txt | Doc. | Documentation | ||
LICENSE.md | Lic. | License text | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (52) | / | script |
File | Role | Description |
---|---|---|
bootstrap | Data | Auxiliary data |
setperm | Data | Auxiliary data |
test | Data | Auxiliary data |
updatedeps | Data | Auxiliary data |
Files (52) | / | src |
File | Role | Description | ||
---|---|---|---|---|
Annotation (1 file) | ||||
Command (2 directories) | ||||
DependencyInjection (2 files, 1 directory) | ||||
Entity (4 files) | ||||
Manager (1 file) | ||||
Model (4 files) | ||||
Queue (4 files) | ||||
Resources (1 directory) | ||||
Schedule (1 file) | ||||
Synchronizer (1 file) | ||||
Task (5 files) | ||||
Tests (3 directories) | ||||
GloobyTaskBundle.php | Class | Class source |
Files (52) | / | src | / | Command | / | Scheduler |
File | Role | Description |
---|---|---|
PruneCommand.php | Class | Class source |
RunCommand.php | Class | Class source |
SyncCommand.php | Class | Class source |
Files (52) | / | src | / | DependencyInjection |
File | Role | Description | ||
---|---|---|---|---|
Compiler (1 file) | ||||
Configuration.php | Class | Class source | ||
GloobyTaskExtension.php | Class | Class source |
Files (52) | / | src | / | DependencyInjection | / | Compiler |
File | Role | Description |
---|---|---|
RegisterSchedulesPass.php | Class | Class source |
Files (52) | / | src | / | Entity |
File | Role | Description |
---|---|---|
QueuedTask.php | Class | Class source |
QueuedTaskRepository.php | Class | Class source |
Schedule.php | Class | Class source |
ScheduleRepository.php | Class | Class source |
Files (52) | / | src | / | Model |
File | Role | Description |
---|---|---|
QueuedTask.php | Class | Class source |
QueuedTaskInterface.php | Class | Class source |
Schedule.php | Class | Class source |
ScheduleInterface.php | Class | Class source |
Files (52) | / | src | / | Queue |
File | Role | Description |
---|---|---|
QueueMonitor.php | Class | Class source |
QueueProcessor.php | Class | Class source |
QueuePruner.php | Class | Class source |
QueueScheduler.php | Class | Class source |
Files (52) | / | src | / | Task |
File | Role | Description |
---|---|---|
OutputAwareInterface.php | Class | Class source |
PingTask.php | Class | Class source |
QueuedTaskAwareInterface.php | Class | Class source |
TaskInterface.php | Class | Class source |
TaskRunner.php | Class | Class source |
Files (52) | / | src | / | Tests |
File | Role | Description | ||
---|---|---|---|---|
Annotation (1 file) | ||||
DependencyInjection (2 files, 2 directories) | ||||
Schedule (1 file) |
Files (52) | / | src | / | Tests | / | DependencyInjection |
File | Role | Description | ||
---|---|---|---|---|
Complier (1 file) | ||||
fixtures (1 file) | ||||
ConfigurationTest.php | Class | Class source | ||
GloobyTaskExtensionTest.php | Class | Class source |
Files (52) | / | src | / | Tests | / | DependencyInjection | / | Complier |
File | Role | Description |
---|---|---|
RegisterSchedulesPassTest.php | Class | Class source |
Files (52) | / | src | / | Tests | / | DependencyInjection | / | fixtures |
File | Role | Description |
---|---|---|
config.yml | Data | Auxiliary data |
Files (52) | / | src | / | Tests | / | Schedule |
File | Role | Description |
---|---|---|
ScheduleRegistryTest.php | Class | Class source |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.