Download the PHP package yzh52521/think-aliyunmns-queue without Composer

On this page you can find all versions of the php package yzh52521/think-aliyunmns-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-aliyunmns-queue

think-aliyunmns-queue

介绍

针对ThinkPHP5.1的队列(thinkphp-queue)做了阿里云消息队列的扩展,方便想使用阿里云消息队列同学快速开发。

安装教程

composer require yzh52521/think-aliyunmns-queue

使用说明

配置

配置文件位于 config/queue.php

监听任务并执行

php think queue:listen // 适合任务少,任务不确定性

php think queue:work --daemon // 适合对性能有要求的,并且任务执行时间要短

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

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

创建任务类

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

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

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

例子1:

例子2:

发布任务

think\facade\Queue::push($job, $data = '', $queue = null) 和 think\facade\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@task1、app\lib\job\Job2@task2

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

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

详细说明文档请参阅thinkphp-queue文档


All versions of think-aliyunmns-queue with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
topthink/think-queue Version ~2.0
aliyun/aliyun-mns-php-sdk Version ^1.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 yzh52521/think-aliyunmns-queue contains the following files

Loading the files please wait ....