utopia-php / queue
一个强大的任务队列。
0.8.0
2024-09-05 16:33 UTC
Requires
- php: >=8.0
- utopia-php/cli: 0.19.*
- utopia-php/di: 0.1.*
- utopia-php/servers: 0.1.*
Requires (Dev)
- laravel/pint: ^0.2.3
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5.5
- swoole/ide-helper: 4.8.8
- workerman/workerman: ^4.0
Suggests
- ext-redis: Needed to support Redis connections
- ext-swoole: Needed to support Swoole.
- workerman/workerman: Needed to support Workerman.
- dev-main
- 0.8.0
- 0.8.0-RC1
- 0.7.0
- 0.6.0
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-add-support-for-concurrency
- dev-feat-use-utopia-docker-base
- dev-feat-multiqueue-server
- dev-feat-github-action
- dev-feat-framework-v2-v2
- dev-feat-get-worker-start
- dev-feat-framework-v2
- dev-fix-error-callback
- dev-promote-new-cli-version
- dev-fix-reset-resources
- dev-feat-connection-ping
- dev-upgrade-libs
- dev-readme-fixes
- dev-feat-di-in-worker-start
- dev-qa-fixes
This package is auto-updated.
Last update: 2024-09-10 10:28:57 UTC
README
Utopia Queue 是一个强大的队列库。这个库的目标是尽可能简单、易于学习和使用。该库由 Appwrite 团队 维护。
尽管这个库是 Utopia 框架 项目的一部分,但它不依赖于任何其他库,可以独立于任何其他 PHP 项目或框架使用。
入门指南
使用 composer 安装
composer require utopia-php/queue
在您的应用程序中初始化
<?php require_once __DIR__ . '/../../vendor/autoload.php'; // Create a worker using the Swoole adapter use Utopia\Queue; use Utopia\Queue\Message; $connection = new Queue\Connection\Redis('redis'); if ($connection->ping()) { var_dump('Connection is ready.'); } else { var_dump('Connection is not ready.'); } $adapter = new Queue\Adapter\Swoole($connection, 12, 'my-queue'); $server = new Queue\Server($adapter); $server ->job() ->inject('message') ->action(function (Message $message) { var_dump($message); }); $server ->error() ->inject('error') ->action(function ($error) { echo $error->getMessage() . PHP_EOL; }); $server ->workerStart() ->action(function () { echo "Worker Started" . PHP_EOL; }); $server->start(); // Enqueue messages to the worker using the Redis adapter $connection = new Redis('redis', 6379); $client = new Client('my-queue', $connection); $client->enqueue([ 'type' => 'test_number', 'value' => 123 ]);
系统需求
Utopia 框架需要 PHP 8.0 或更高版本。我们建议在可能的情况下使用最新的 PHP 版本。
版权和许可
MIT 许可证 (MIT) http://www.opensource.org/licenses/mit-license.php