Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit 02a8f51

Browse files
author
Raül Pérez
committed
Merge branch 'release/0.0.1'
2 parents bda0903 + d1c41e0 commit 02a8f51

14 files changed

Lines changed: 655 additions & 1 deletion

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.contrib
2+
vendor
3+
cover
4+
*.phar
5+
composer.lock

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015 Raül Pérez
3+
Copyright (c) 2015 repejota@gmail.com
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

README.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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)

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

composer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
}

examples/connect.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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();

examples/ping.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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();

examples/pubsub/pub.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
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");

0 commit comments

Comments
 (0)