Download the PHP package xiaosongshu/rabbitmq without Composer

On this page you can find all versions of the php package xiaosongshu/rabbitmq. 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 rabbitmq

rabbitmq queue 消息队列

项目地址:https://github.com/2723659854/rabbitmq

项目介绍

消息队列主要用于耗时业务解耦,本项目采用rabbitmq扩展,支持thinkPHP,laravel,webman,yii等常用框架,也可以单独使用。
本项目经过实际生产环境测试,可以放心使用。编写此插件的原因是,有些公司项目极其老旧,而这些项目本身不支持rabbitmq队列解耦复杂业务,而市面上新版的插件 直接安装使用会各种冲突,抛出各种异常,所以作者决定自己手搓了一个。

安装方法 install

示例 demo

本实例你可以直接复制粘贴到本地测试。

定义一个队列 queue

编写一个客户端server.php文件,内容如下:

投递消息 publish

编写一个publish.php文件,内容如下:

你可以在任何地方投递消息。

创建消费者

创建一个consume.php文件,内容如下:

如果你的操作系统是windows环境,而且你如果开启了死信队列。那么还需要建一个文件consumeD.php用来消费死信队列的消息,内容如下:

在编写完以上文件之后,就可以测试了。
开启普通消息消费,在新的cmd窗口执行:

开启死信消息消费(仅限windows系统,并且开启了死信队列。linux系统不需要此命令,会自动维护死信消息的消费),在新的cmd窗口执行:

投递消息,在新的cmd窗口执行:

完成以上步骤后,你将会在消费者cmd窗口看到消息被投递和消费。
而若需要关闭消费和投递,可以直接按键ctrl + c 停止执行。

在常用框架中的应用举例

你可以把消费者放到command命令行里面,使用命令行执行队列消费。举个例子(这里以yii为例子,你也可以换成laravel,webman,thinkPHP等其他框架):

yii中的应用举例

构建一个客户端

将消费者写入到命令行工具里面。

开启消费者命令 consume(你可以开启多个窗口执行此命令实现开启多个消费者的目的),

如果你在linux环境下想实现无人值守模式,命令如下(你可以多次执行此命令,实现开启多个消费者的目的):

投递消息方式如下,你可以在任何地方包括但不限于控制器或命令行,写入以下命令:

注:如果你需要开启多个消费者,那么可以在多个窗口执行开启消费者命令即可。当然你也可以使用多进程来处理。

关闭消费者

thinkphp中的应用举例

以下是在thinphp框架中植入队列的示例,仅供参考。(作者在thinkphp3.2和5.1中已测试过,当前实例版本是5.1)
首先创建客户端服务类RabbitmqService.php,内容如下:

启动消费者,我们使用thinkphp的命令行工具实现,内容如下:

开启消费命令如下(你可以开启多个窗口执行此命令实现开启多个消费者的目的):

如果需要在linux上已无人值守模式运行,命令如下(你可以多次执行此命令,实现开启多个消费者的目的):

如果你的是windows系统,需要测试死信队列,那么还需要创建一个死信队列的消费者,内容如下:

开启死信消费者命令是(你可以开启多个窗口执行此命令实现开启多个消费者的目的):

若需要在linux环境下无人值守模式运行,命令如下(你可以多次执行此命令,实现开启多个消费者的目的):

投递消息:你可以在任何地方投递消息,包括但不限于控制器、命令行,只需要在代码中加入以下方法即可投递消息:

作者尽量将本插件的使用方法贴出了示例,是希望各位用户明白使用方法,但是天下框架何其多,也不可能给所有的框架写示例。当明白了使用方法的时候,任何框架都可以嫁接进去使用。 当然了,希望你不要照搬我的示例,因为我的代码仅仅是示例,可能不完全符合你的业务需求。

异常 Exception

队列使用过程中请使用 \RuntimeException和\Exception捕获异常

若需要使用延迟队列,那么rabbitmq服务需要安装延迟插件,否则会报错

联系作者:[email protected] ,你也可以直接提issues

All versions of rabbitmq with dependencies

PHP Build Version
Package Version
Requires php Version >=7.3.0
phpseclib/phpseclib Version ^3.0
php-amqplib/php-amqplib Version 3.2.*
ext-json Version *
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 xiaosongshu/rabbitmq contains the following files

Loading the files please wait ....