https://github.com/missinglink/mongrel2-php
Simple library for writing Mongrel2 clients in PHP 5.3+ using zmq zeromq 2.2
https://github.com/missinglink/mongrel2-php
Last synced: about 1 year ago
JSON representation
Simple library for writing Mongrel2 clients in PHP 5.3+ using zmq zeromq 2.2
- Host: GitHub
- URL: https://github.com/missinglink/mongrel2-php
- Owner: missinglink
- Created: 2012-05-20T23:30:09.000Z (about 14 years ago)
- Default Branch: master
- Last Pushed: 2013-05-03T20:48:05.000Z (about 13 years ago)
- Last Synced: 2025-03-24T10:11:30.966Z (about 1 year ago)
- Language: PHP
- Homepage:
- Size: 406 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Simple library for writing Mongrel2 clients in PHP 5.3+ using zeromq 2.2
========================================================================
Install
--------
```bash
echo '[Installing ØMQ 2.2]' && ./install/zmq22-install.sh
echo '[Installing ØMQ PHP Module]' && ./install/zmqphp-install.sh
echo '[Installing pecl_http Module]' && ./install/pecl-http-install.sh
echo '[Installing Composer]' && curl -s http://getcomposer.org/installer | php && php composer.phar install
echo '[Installing Mongrel2 Web Server]' && ./install/mongrel2-zmq2-install.sh
```
Simple Client Example
---------------------
```php
// Create a new Mongrel client
$mongrelClient = new \Mongrel\Client(
new \ZMQContext,
new \Mongrel\Dsn( 'tcp://127.0.0.1:9997' ),
new \Mongrel\Dsn( 'tcp://127.0.0.1:9996' )
);
// Create a new Mongrel HTTP client
$client = new \Mongrel\Http\Client( $mongrelClient );
// Listen for requests
while( true )
{
/* @var $request \Mongrel\Http\Request */
$request = $client->recv();
// Build a response
$response = new \Mongrel\Http\Response( '
Hello World!
', array( 'Content-Type' => 'text/html' ) );
// Send response back to the browser that requested it
$client->reply( $response, $request );
// Clean up
unset( $request, $response );
}
```
Mustache View Renderer Example
------------------------------
```bash
sh examples/mongrel-start.sh
sh examples/mustache/devices/mustache-server.sh # (in another window)
```
Open [localhost:8001](http://localhost:8001/) in your web browser
Tests
--------
```bash
phpunit
```
Travis CI
---------
 http://travis-ci.org/#!/missinglink/mongrel2-php

License
------------------------
Released under the MIT(Poetic) Software license
This work 'as-is' we provide.
No warranty express or implied.
Therefore, no claim on us will abide.
Liability for damages denied.
Permission is granted hereby,
to copy, share, and modify.
Use as is fit,
free or for profit.
These rights, on this notice, rely.