winks / m2php
PHP bindings for mongrel2
Installs: 4 458
Dependents: 1
Suggesters: 0
Security: 0
Stars: 80
Watchers: 10
Forks: 14
Open Issues: 4
Requires
- php: >=5.3.0
- ext-zmq: *
This package is not auto-updated.
Last update: 2024-11-23 12:39:01 UTC
README
- Mongrel2: http://mongrel2.org
- Mongrel2 Python Library: http://sheddingbikes.com/posts/1279007133.html
Requirements
- ZeroMQ 2.0.7 or later: http://www.zeromq.org/
- PHP 5.3: http://php.net
- ZeroMQ PHP bindings: http://www.zeromq.org/bindings:php
Fetch
The recommended way to install m2php is through composer.
Just create a composer.json file for your project:
{
"require": {
"winks/m2php": "dev-master"
}
}
And run these two commands to install it:
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
Now you can add the autoloader, and you will have access to the library:
<?php require 'vendor/autoload.php';
Usage
<?php use Mongrel2\Connection; $sender_id = "82209006-86FF-4982-B5EA-D1E29E55D481"; $conn = new Connection($sender_id, "tcp://127.0.0.1:9997", "tcp://127.0.0.1:9996"); while (true) { $req = $conn->recv(); if ($req->is_disconnect()) { continue; } $conn->reply_http($req, 'Hello World'); }
Example
Before running the example, you need to have composer set up an autoloader:
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
Now you can run the example.
$ cd example
$ m2sh load
$ m2sh start
# in a separate shell
$ php hello.php
# in a separate shell or browser
$ curl http://localhost:6767/hello
Tests
Before running the tests you need to have composer set up an autoloader:
$ curl -sS https://getcomposer.org/installer | php
$ php composer.phar install
Now you can run the unit tests.
$ phpunit
LICENSE
New BSD, see LICENSE.