PHP code example of yosymfony / httpserver

1. Go to this page and download the library: Download yosymfony/httpserver library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yosymfony / httpserver example snippets


$requestHandler = new RequestHandler( function($request) {
    return 'Hi Yo! Symfony';
});

$requestHandler->listen(8081, '127.0.0.1');

$requestHandler = new RequestHandler( function($request) {
    return 'Hi Yo! Symfony';
});

$requestHandler
    ->listen(8081, '127.0.0.1')
    ->enableHttpFoundationRequest(); // $requestHandler uses fluent interface

$requestHandler = new RequestHandler( function($request) {
    return 'Hi Yo! Symfony';
});

requestHandler = new RequestHandler( function($request) {
    return [
        'content' => '<?xml version="1.0" encoding="UTF-8"

use Symfony\Component\HttpFoundation\Response;

requestHandler = new RequestHandler( function($request) {
    return new Response(
        'Hi Yo! Symfony',
        Response::HTTP_OK,
        array('content-type' => 'text/html')
    );
});