Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify how to add jobs #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ Queues are defined in the config file. Pass them as an associative array: `[name

### Add jobs

Add the following code into a controller or where ever you want to execute it.

```php
$myQueue = kqQueue("queuename"); // "queuename must be the same as set in the options
$myJob = kqJob([ // Pass the variables needed in the handler
Expand All @@ -72,6 +74,28 @@ $myJob = kqJob([ // Pass the variables needed in the handler
$myQueue->addJob($myJob);
```

For testing purposes create a route

```php
// config.php
'routes' => [
[
'pattern' => 'addtokirbyqueue/queuename',
'action' => function () {
$myQueue = kqQueue("queuename"); // "queuename must be the same as set in the options
$myJob = kqJob([ // Pass the variables needed in the handler
'foo' => "foo",
'bar' => "bar",
]);
$myQueue->addJob($myJob);
exit;
},
]
]
```

and then call http://localhost/addtokirbyqueue/queuename to fill the queue

### Schedule jobs

```php
Expand Down Expand Up @@ -106,4 +130,4 @@ This plugin is provided "as is" with no guarantee. Use it at your own risk and a

[MIT](https://opensource.org/licenses/MIT)

It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.
It is discouraged to use this plugin in any project that promotes racism, sexism, homophobia, animal abuse, violence or any other form of hate speech.