GithubHelp home page GithubHelp logo

m2php's Introduction

m2php - a library to develop Mongrel2 handlers in PHP

Requirements

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.

m2php's People

Contributors

igorw avatar javiern avatar winks avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.