This repository was archived by the owner on Oct 30, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ .contrib
2+ vendor
3+ cover
4+ * .phar
5+ composer.lock
Original file line number Diff line number Diff line change 1+ language : php
2+ php :
3+ - 5.4
4+ - 5.5
5+ - 5.6
6+ - hhvm
7+ - nightly
8+ install :
9+ - composer update
10+ - make lint
Original file line number Diff line number Diff line change 11The MIT License (MIT)
22
3- Copyright (c) 2015 Raül Pérez
3+ Copyright (c) 2015 repejota@gmail.com
44
55Permission is hereby granted, free of charge, to any person obtaining a copy
66of this software and associated documentation files (the "Software"), to deal
Original file line number Diff line number Diff line change 1+ lint :
2+ find src -name * .php -exec php -l {} \;
3+ find tests -name * .php -exec php -l {} \;
4+ find examples -name * .php -exec php -l {} \;
5+
6+ test :
7+ ./vendor/bin/phpunit
8+
9+ cover :
10+ ./vendor/bin/phpunit --coverage-html ./cover
11+
12+ cs :
13+ ./phpcbf.phar src
14+ ./phpcbf.phar tests
15+ ./phpcbf.phar examples
16+ ./phpcs.phar src tests examples
Original file line number Diff line number Diff line change 1+ phpnats
2+ =======
3+
4+ ** Travis**
5+
6+ * Master: [ ![ Build Status] ( https://travis-ci.org/repejota/phpnats.png?branch=master )] ( https://travis-ci.org/repejota/phpnats )
7+ * Develop: [ ![ Build Status] ( https://travis-ci.org/repejota/phpnats.png?branch=develop )] ( https://travis-ci.org/repejota/phpnats )
8+
9+ ** Insight**
10+
11+ * [ ![ SensioLabsInsight] ( https://insight.sensiolabs.com/projects/3fb84121-278d-489f-8394-d95c3e3b05d2/mini.png )] ( https://insight.sensiolabs.com/projects/3fb84121-278d-489f-8394-d95c3e3b05d2 )
12+
13+
14+ A PHP client for the [ NATS messaging system] ( https://nats.io ) .
15+
16+ > Note: phpnats is under heavy development.
17+
18+ Requirements
19+ ------------
20+
21+ * php ~ 5.3
22+ * [ nats] ( https://github.com/derekcollison/nats ) or [ gnatsd] ( https://github.com/apcera/gnatsd )
23+
24+
25+ Usage
26+ -----
27+
28+ ### Basic Usage
29+
30+ ``` php
31+ $client = new \Nats\Connection(verbose=True);
32+ $client->connect();
33+
34+ # Simple Publisher
35+ $client->publish("foo", "foo bar");
36+
37+ # Simple Subscriber
38+ $callback = function($payload)
39+ {
40+ printf("Data: %s\r\n", $payload);
41+ };
42+ $client->subscribe("foo", $callback);
43+
44+ # Wait for 1 message
45+ $client->wait(1);
46+ ```
47+
48+
49+ Tests
50+ -----
51+
52+ Tests are in the ` tests ` folder.
53+ To run them, you need ` PHPUnit ` and execute ` make test ` .
54+
55+
56+ License
57+ -------
58+
59+ MIT, see [ LICENSE] ( LICENSE )
Original file line number Diff line number Diff line change 1+ 0.0.1
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " repejota/nats" ,
3+ "description" : " A nats.io client in PHP" ,
4+ "type" : " library" ,
5+ "minimum-stability" : " dev" ,
6+ "license" : " MIT" ,
7+ "authors" : [{
8+ "name" : " Raül Pérez" ,
9+ "email" : " repejota@gmail.com" ,
10+ "homepage" : " http://repejota.com"
11+ }],
12+ "require" : {},
13+ "require-dev" : {
14+ "phpunit/phpunit" : " 4.7.*"
15+ },
16+ "autoload" : {
17+ "psr-4" : {
18+ "Nats\\ " : " src"
19+ }
20+ },
21+ "autoload-dev" : {
22+ "psr-4" : {
23+ "Tests\\ Nats\\ " : " tests/Unit"
24+ }
25+ }
26+ }
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Connection example
4+ *
5+ * PHP version 5
6+ *
7+ * @category Script
8+ * @package Nats
9+ * @author Raül Përez <repejota@gmail.com>
10+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11+ * @link https://github.com/repejota/phpnats
12+ */
13+ require_once "../vendor/autoload.php " ;
14+
15+ const HOST = "localhost " ;
16+ const PORT = 4222 ;
17+
18+ echo "Server: nats:// " . HOST . ": " . PORT . PHP_EOL ;
19+ $ c = new Nats \Connection ();
20+ echo "Connecting ... " . PHP_EOL ;
21+ $ c ->connect ();
22+ echo "Disconnecting ... " . PHP_EOL ;
23+ $ c ->close ();
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * PING example
4+ *
5+ * PHP version 5
6+ *
7+ * @category Script
8+ * @package Nats
9+ * @author Raül Përez <repejota@gmail.com>
10+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11+ * @link https://github.com/repejota/phpnats
12+ */
13+ require_once "../vendor/autoload.php " ;
14+
15+ const HOST = "localhost " ;
16+ const PORT = 4222 ;
17+
18+ echo "Server: nats:// " . HOST . ": " . PORT . PHP_EOL ;
19+ $ c = new Nats \Connection ();
20+ $ c ->connect ();
21+
22+ $ c ->ping ();
Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Publisher example
4+ *
5+ * PHP version 5
6+ *
7+ * @category Script
8+ * @package Nats
9+ * @author Raül Përez <repejota@gmail.com>
10+ * @license http://opensource.org/licenses/MIT The MIT License (MIT)
11+ * @link https://github.com/repejota/phpnats
12+ */
13+ require_once "../../vendor/autoload.php " ;
14+
15+ const HOST = "localhost " ;
16+ const PORT = 4222 ;
17+
18+ $ c = new Nats \Connection ();
19+ $ c ->connect ();
20+
21+ $ c ->reconnect ();
22+
23+ $ c ->publish ("foo " , "bar " );
24+ $ c ->publish ("foo " , "bar " );
25+ $ c ->publish ("foo " , "bar " );
26+ $ c ->publish ("foo " , "bar " );
27+ $ c ->publish ("foo " , "bar " );
You can’t perform that action at this time.
0 commit comments