|
1 | | -# CodeIgniter 4 Tasks |
| 1 | +# CodeIgniter Tasks |
2 | 2 |
|
3 | | -A task scheduler for CodeIgniter 4. |
| 3 | +A task scheduler for CodeIgniter 4. |
4 | 4 |
|
5 | | -**NOTE: Just starting development. Not for active consumption or it WILL make your app sick.** |
| 5 | +## Installation |
6 | 6 |
|
7 | | -My "to-do list" for this module: |
| 7 | +Install via Composer: |
8 | 8 |
|
9 | | -- provides commands to view when tasks are scheduled to run. Can list all for this week, or on a specific day. |
10 | | -- command to run any job manually |
11 | | -- command to disable/enable a job |
12 | | -- should have a variety of ways to notify when done, like logging, email, etc |
13 | | -- must be able to call shell commands |
14 | | -- must be able to run closures |
15 | | -- must be able to run commands |
16 | | -- restrict by environment |
17 | | -- can specify the timezone |
18 | | -- should collect performance information (in writeable as csv) |
19 | | -- command to view performance (https://github.com/codestudiohq/laravel-totem) |
20 | | -- provide a debug toolbar pane |
| 9 | + composer require codeigniter4/tasks |
21 | 10 |
|
22 | | -## How to Try |
| 11 | +Migrate the database: |
23 | 12 |
|
24 | | -1. Add the following in your project's `composer.json`: |
| 13 | + php spark migrate --all |
25 | 14 |
|
26 | | -``` |
27 | | - "require": { |
28 | | - "codeigniter4/tasks": "dev-develop" |
29 | | - }, |
30 | | -``` |
31 | | - |
32 | | -``` |
33 | | - "repositories": [ |
34 | | - { |
35 | | - "type": "vcs", |
36 | | - "url": "https://github.com/codeigniter4/tasks.git" |
37 | | - } |
38 | | - ], |
39 | | -``` |
40 | | - |
41 | | -2. Run `composer update`. |
| 15 | +## Configuration |
42 | 16 |
|
43 | | -3. Run `php spark migrate --all`. |
| 17 | +Publish the config file: |
44 | 18 |
|
45 | | -4. Copy `vendor/codeigniter4/settings/src/Config/Tasks.php` into `app/Config/`. |
| 19 | + php spark tasks:publish |
46 | 20 |
|
47 | | -5. Update the namespace in `app/Config/Tasks.php`. |
| 21 | +## Defining tasks |
48 | 22 |
|
49 | | -```php |
50 | | -<?php |
| 23 | +Define your tasks in the `init()` method: |
51 | 24 |
|
52 | | -namespace CodeIgniter\Tasks\Config; |
53 | | -``` |
54 | | -↓ |
55 | 25 | ```php |
| 26 | +// app/Config/Tasks.php |
56 | 27 | <?php |
57 | 28 |
|
58 | 29 | namespace Config; |
| 30 | + |
| 31 | +use CodeIgniter\Tasks\Config\Tasks as BaseTasks; |
| 32 | +use CodeIgniter\Tasks\Scheduler; |
| 33 | + |
| 34 | +class Tasks extends BaseTasks |
| 35 | +{ |
| 36 | + /** |
| 37 | + * Register any tasks within this method for the application. |
| 38 | + * |
| 39 | + * @param Scheduler $schedule |
| 40 | + */ |
| 41 | + public function init(Scheduler $schedule) |
| 42 | + { |
| 43 | + $schedule->command('demo:refresh --all')->mondays('11:00 pm'); |
| 44 | + } |
| 45 | +} |
59 | 46 | ``` |
| 47 | + |
| 48 | +## Docs |
| 49 | + |
| 50 | +Read the full documentation: https://codeigniter4.github.io/tasks/ |
0 commit comments