wallrio/onservice

Interface for creating servers and services

2.0.5 2019-05-14 03:35 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\Router as Router;

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

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

Example
$server->router->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\Router as Router;
use onservice\services\Process as Process;

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

Available services

License

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