version wamp 2.4
1.打开openssl
分别更改php.ini的文件配置
E:\wamp\bin\apache\Apache2.4.4\bin\php.ini
E:\wamp\bin\apache\Apache2.4.4\bin\php.ini
php.ini的功能打开
extension=php_openssl.dll
2.Composer下载
https://getcomposer.org/Composer-Setup.exe
下载完成直接点下一步图型安装……
3.php-amqplib下载
https://github.com/videlalvaro/php-amqplib/archive/master.zip
加压后复制PhpAmqpLib文件夹到项目根目录下
4.根目录下创建文件:composer.json
{
"require": {
"videlalvaro/php-amqplib": "2.2.*"
}
}
5.cmd命令行安装php-amqplib:
E:\wamp\bin\php\php5.4.16>E:\wamp\bin\php\php5.4.16/php.exe composer
Could not open input file: composer
E:\wamp\bin\php\php5.4.16>php composer.phar
Could not open input file: composer.phar
E:\wamp\bin\php\php5.4.16>composer update friendsofsymfony/user-bundle
Composer could not find a composer.json file in E:\wamp\bin\php\php5.4.16
To initialize a project, please create a composer.json file as described in the
http://getcomposer.org/ "Getting Started" section
到项目跟目录安装php-amqplib
E:\wamp\www\gx> composer update friendsofsymfony/user-bundle
Package "friendsofsymfony/user-bundle" listed for update is not installed. Ignor
ing.
Loading composer repositories with package information
Updating dependencies (including require-dev)
- Installing videlalvaro/php-amqplib (v2.2.6)
Downloading: 100%
Writing lock file
Generating autoload files
6.环境完成开始测试
send.php
<?php
require_once __DIR__ . ‘/vendor/autoload.php‘;
use PhpAmqpLib\Connection\AMQPConnection;
use PhpAmqpLib\Message\AMQPMessage;
$connection = new AMQPConnection(‘192.168.99.104‘, 5672, ‘guest‘, ‘guest‘);
$channel = $connection->channel();
$channel->queue_declare(‘hello‘, false, false, false, false);
$data = implode(‘ ‘, array_slice($argv, 1));
if(empty($data)) $data = "Hello World!";
$msg = new AMQPMessage($data,
array(‘delivery_mode‘ => 2) # make message persistent
);
$channel->basic_publish($msg, ‘‘, ‘hello‘);
echo " [x] Sent ", $data, "\n";
$channel->close();
$connection->close();
?>
receive.php
<?php
require_once __DIR__ . ‘/vendor/autoload.php‘;
use PhpAmqpLib\Connection\AMQPConnection;
$connection = new AMQPConnection(‘192.168.99.104‘, 5672, ‘guest‘, ‘guest‘);
$channel = $connection->channel();
$channel->queue_declare(‘hello‘, false, false, false, false);
echo ‘ [*] Waiting for messages. To exit press CTRL+C‘, "\n";
$callback = function($msg){
echo " [x] Received ", $msg->body, "\n";
sleep(substr_count($msg->body, ‘.‘));
echo " [x] Done", "\n";
$msg->delivery_info[‘channel‘]->basic_ack($msg->delivery_info[‘delivery_tag‘]);
};
$channel->basic_qos(null, 1, null);
$channel->basic_consume(‘hello‘, ‘‘, false, false, false, false, $callback);
while(count($channel->callbacks)) {
$channel->wait();
}
?>
7.cmd命令行测试:
发送消息:
E:\wamp\www\gx>php send.php 终于测试成功了
[x] Sent 终于测试成功了
E:\wamp\www\gx>php send.php wamp2.4+rabbitmq 测试通过
[x] Sent wamp2.4+rabbitmq 测试通过
接受消息:
E:\wamp\www\gx>php receive.php
[*] Waiting for messages. To exit press CTRL+C
[x] Received 终于测试成功了
[x] Done
[x] Received wamp2.4+rabbitmq 测试通过
[x] Done
本文出自 “yanzi” 博客,请务必保留此出处http://daddysgirl.blog.51cto.com/1598612/1436412
wamp2.4+composer+rabbitmq环境部署-176,布布扣,bubuko.com
wamp2.4+composer+rabbitmq环境部署-176
原文地址:http://daddysgirl.blog.51cto.com/1598612/1436412