https://github.com/devuri/queue-job-slim
Queue the job for slim
https://github.com/devuri/queue-job-slim
Last synced: 11 months ago
JSON representation
Queue the job for slim
- Host: GitHub
- URL: https://github.com/devuri/queue-job-slim
- Owner: devuri
- Created: 2018-05-19T15:58:42.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-05-06T06:17:25.000Z (almost 8 years ago)
- Last Synced: 2024-10-19T14:21:35.703Z (over 1 year ago)
- Language: PHP
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# rodrigoiii/queue-job-slim
Don't let your visitor wait to finish the process of your application.
The goal of this library is to ease the loading process.
Just create the job and let it do that for you.
## Setup for server side
I assume you are using slim micro framework. If not ignore this library.
Create file `server.php` or any name do you want and include the `autoload.php` file.
Instantiate your worker and put the host.
```php
$queue = new QueueJobSlim\Worker("127.0.0.1");
```
Then put your jobs to watch it.
```php
$queue->listen(["PunchUp", "PunchDown"]);
```
After all, just run it in the terminal/console. Like `php server.php`
## Setup for client side
Put your queue-job settings in slim application like below.
```php
$app = new Slim\App([
'settings' => [
'displayErrorDetails' => true,
'queue-job' => [
'host' => "127.0.0.1", // this is host
'job_namespace' => "Example\Jobs" // this is where your jobs location
]
]
]);
```
Get the container of application (this is must because the library will fetch it globally).
```php
$container = $app->getContainer();
```
And then produce what job you want to process.
```php
$app->get('/test', function ()
{
QueueJobSlim\Producer::send("PunchDown"); // Call the PunchDown job
QueueJobSlim\Producer::send("PunchUp", ["ouch"]); // Call the PunchUp job with argument "ouch"
});
$app->run();
```
Checkout the demo in this link https://github.com/rodrigoiii/queue-job-slim/tree/master/example.