Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nepster-web/php-simple-queue
Simple php queue implementation through database.
https://github.com/nepster-web/php-simple-queue
Last synced: about 1 month ago
JSON representation
Simple php queue implementation through database.
- Host: GitHub
- URL: https://github.com/nepster-web/php-simple-queue
- Owner: nepster-web
- License: mit
- Created: 2021-02-11T14:43:18.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-05-08T20:19:38.000Z (over 3 years ago)
- Last Synced: 2024-11-06T20:51:16.362Z (about 2 months ago)
- Language: PHP
- Homepage:
- Size: 1.32 MB
- Stars: 18
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
> This package is under development. Api classes of this application can be changed.
PHP Simple Queue
Introduction
------------**PHP Simple Queue** - a library for running tasks asynchronously via queues.
It is production ready, battle-tested a simple messaging solution for PHP.It supports queues based on **DB**.
Requirements
------------You'll need at least PHP 7.4 (it works best with PHP 8).
Installation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/):
Either run
```
php composer.phar require --prefer-dist nepster-web/php-simple-queue
```or add
```
"nepster-web/php-simple-queue": "*"
```:computer: Basic Usage
----------------------Create transport ([see more information](./docs/guide/transport.md)):
```php
$transport = new \Simple\Queue\Transport\DoctrineDbalTransport($connection);
```### Send a new message to queue (producing)
```php
$config = \Simple\Queue\Config::getDefault()
->registerProcessor('my_queue', static function(\Simple\Queue\Context $context): string {
// Your message handling logic
return \Simple\Queue\Consumer::STATUS_ACK;
});
$producer = new \Simple\Queue\Producer($transport, $config);$message = $producer->createMessage('my_queue', ['key' => 'value']);
$producer->send($message);
```### Job dispatching (producing)
```php
$config = \Simple\Queue\Config::getDefault()
->registerJob(MyJob::class, new MyJob());$producer = new \Simple\Queue\Producer($transport, $config);
$producer->dispatch(MyJob::class, ['key' => 'value']);
```### Processing messages from queue (consuming)
```php
$producer = new \Simple\Queue\Producer($transport, $config);
$consumer = new \Simple\Queue\Consumer($transport, $producer, $config);$consumer->consume();
```For more details see the [example code](./example) and read the [guide](./docs/guide/example.md).
### Testing
To run the tests locally, in the root directory execute below
```
./vendor/bin/phpunit
```or you can run tests in a docker container
```
cd .docker
make build
make start
make composer cmd='test'
```---------------------------------
## :book: Documentation
See [the official guide](./docs/guide/README.md).
## :books: Resources
* [Documentation](./docs/guide/README.md)
* [Example](./example)
* [Issue Tracker](https://github.com/nepster-web/php-simple-queue/issues)## :newspaper: Changelog
Detailed changes for each release are documented in the [CHANGELOG.md](./CHANGELOG.md).
## :lock: License
See the [MIT License](LICENSE) file for license rights and limitations (MIT).