8000 Merge pull request #23 from videlalvaro/master · sysumjc/rabbitmq-tutorials@2887586 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2887586

Browse files
author
Michael Klishin
committed
Merge pull request rabbitmq#23 from videlalvaro/master
moves PHP examples to videlalvaro/php-amqplib
2 parents c1aa2d8 + 1fd024d commit 2887586

File tree

10 files changed

+34
-16
lines changed

10 files changed

+34
-16
lines changed

php/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ Additionally you need `PHP 5.3` and `php-amqplib`. To get these
1212
dependencies on Ubuntu type:
1313

1414
sudo apt-get install git-core php5-cli
15-
git clone http://github.com/videlalvaro/php-amqplib.git lib/php-amqplib
1615

17-
Since the tutorials are tested with `php-amqplib` v1.0 you might want to checkout the `v1.0` tag as well:
16+
Then you can install `php-amqplib` using [Composer](http://getcomposer.org).
1817

19-
cd lib/php-amqplib/
20-
git checkout v1.0
18+
To do that install Composer and add it to your path, then run the following command
19+
inside this project folder:
20+
21+
composer.phar install
2122

2223
## Code
2324

php/composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"require": {
3+
"videlalvaro/php-amqplib": "v2.1.0"
4+
}
5+
}

php/emit_log.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
5+
use PhpAmqpLib\Message\AMQPMessage;
46

57
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
68
$channel = $connection->channel();

php/new_task.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
5+
use PhpAmqpLib\Message\AMQPMessage;
46

57
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
68
$channel = $connection->channel();

php/receive.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
45

56
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
67
$channel = $connection->channel();

php/receive_logs.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
45

56
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
67
$channel = $connection->channel();

php/rpc_client.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
5+
use PhpAmqpLib\Message\AMQPMessage;
46

57
class FibonacciRpcClient {
68
private $connection;
@@ -20,7 +22,7 @@ public function __construct() {
2022
array($this, 'on_response'));
2123
}
2224
public function on_response($rep) {
23-
if($rep->properties['correlation_id'] == $this->corr_id) {
25+
if($rep->get('correlation_id') == $this->corr_id) {
2426
$this->response = $rep->body;
2527
}
2628
}

php/rpc_server.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
5+
use PhpAmqpLib\Message\AMQPMessage;
46

57
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
68
$channel = $connection->channel();
@@ -22,11 +24,11 @@ function fib($n) {
2224

2325
$msg = new AMQPMessage(
2426
(string) fib($n),
25-
array('correlation_id' => $req->properties['correlation_id'])
27+
array('correlation_id' => $req->get('correlation_id'))
2628
);
2729

2830
$req->delivery_info['channel']->basic_publish(
29-
$msg, '', $req->properties['reply_to']);
31+
$msg, '', $req->get('reply_to'));
3032
$req->delivery_info['channel']->basic_ack(
3133
$req->delivery_info['delivery_tag']);
3234
};

php/send.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
5+
use PhpAmqpLib\Message\AMQPMessage;
46

57
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
68
$channel = $connection->channel();

php/worker.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?php
22

3-
require_once(__DIR__ . '/lib/php-amqplib/amqp.inc');
3+
require_once __DIR__ . '/vendor/autoload.php';
4+
use PhpAmqpLib\Connection\AMQPConnection;
45

56
$connection = new AMQPConnection('localhost', 5672, 'guest', 'guest');
67
$channel = $connection->channel();
78

8-
99
$channel->queue_declare('task_queue', false, true, false, false);
1010

1111
echo ' [*] Waiting for messages. To exit press CTRL+C', "\n";

0 commit comments

Comments
 (0)
0