wallrio/onservice

Interface for creating servers and services

1.0.5 2018-12-09 04:37 UTC

README

Interface for creating servers and services.

Installation

It's recommended that you use Composer to install Directly.

$ composer require wallrio/onservice "*"

Usage

Creating the server.

<?php

require 'vendor/autoload.php';

use onservice\CreateServer as CreateServer;

$server = new CreateServer();

Usage the service

When creating the server attach the service of interest


use onservice\CreateServer as CreateServer;
use onservice\services\Http as Http;

$server = new CreateServer( new Http() );

After providing the service to the server, you can use all the features that the service provides.

Example
$server->http->resource('/',function($urlPar,$requestPar){

        $html = 'First Page';
        $html .= '<hr>';

        return array(
            'body'=>$html,
            'code'=>200
        );
});

Multiple services


use onservice\CreateServer as CreateServer;
use onservice\services\Http as Http;
use onservice\services\Process as Process;

$server = new CreateServer( new Process(), new Http(),... );

Available services

  • use onservice\services\Http as Http;
  • use onservice\services\LongPolling as LongPolling;
  • use onservice\services\Process as Process;
  • use onservice\services\Database as Database;
  • use onservice\services\Stream as Stream;

more details

License

The OnService is licensed under the MIT license. See License File for more information.