Download the PHP package mwu2019/think-queue without Composer

On this page you can find all versions of the php package mwu2019/think-queue. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package think-queue

think-queue for ThinkPHP5.1

安装

composer require php-amqplib/php-amqplib

composer require mwu2019/think-queue

thinkphp【5.1】自带的queue【版本2.0】增加支持rabbitmq,支持消费者模式、拉取模式。

队列用法示例think-queue https://packagist.org/packages/topthink/think-queue

消费者模式:

php think queue:amqp --queue SaveException2Es --daemon

备注:不带daemon是拉取模式。

更新:
更新延迟队列的命名方式,同一个队列支持多个不同的延迟时间。

修复部分问题:
修改了获取异常,防止无限制获取的问题 vendor\topthink\think-queue\src\queue\Worker.php

配置

配置文件位于 config/queue.php

公共配置

驱动配置

各个驱动的具体可用配置项在think\queue\connector目录下各个驱动类里的options属性中,写在上面的queue配置里即可覆盖

使用 Database

创建如下数据表

创建任务类

单模块项目推荐使用 app\job 作为任务类的命名空间 多模块项目可用使用 app\module\job 作为任务类的命名空间 也可以放在任意可以自动加载到的地方

任务类不需继承任何类,如果这个类只有一个任务,那么就只需要提供一个fire方法就可以了,如果有多个小任务,就写多个方法,下面发布任务的时候会有区别
每个方法会传入两个参数 think\queue\Job $job(当前的任务对象) 和 $data(发布任务时自定义的数据)

还有个可选的任务失败执行的方法 failed 传入的参数为$data(发布任务时自定义的数据)

下面写两个例子

发布任务

think\Queue::push($job, $data = '', $queue = null)think\Queue::later($delay, $job, $data = '', $queue = null) 两个方法,前者是立即执行,后者是在$delay秒后执行

$job 是任务名
单模块的,且命名空间是app\job的,比如上面的例子一,写Job1类名即可
多模块的,且命名空间是app\module\job的,写model/Job1即可
其他的需要些完整的类名,比如上面的例子二,需要写完整的类名app\lib\job\Job2
如果一个任务类里有多个小任务的话,如上面的例子二,需要用@+方法名app\lib\job\Job2@task1app\lib\job\Job2@task2

$data 是你要传到任务里的参数

$queue 队列名,指定这个任务是在哪个队列上执行,同下面监控队列的时候指定的队列名,可不填

监听任务并执行

php think queue:listen

php think queue:work --daemon(不加--daemon为执行单个任务)

两种,具体的可选参数可以输入命令加 --help 查看

可配合supervisor使用,保证进程常驻


All versions of think-queue with dependencies

PHP Build Version
Package Version
Requires topthink/think-helper Version >=1.0.4
topthink/think-installer Version ^2.0
topthink/framework Version 5.1.*
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mwu2019/think-queue contains the following files

Loading the files please wait ....