PHP code example of weew / http-blueprint

1. Go to this page and download the library: Download weew/http-blueprint 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/ */

    

weew / http-blueprint example snippets


// file: blueprint.php

// create a proxy
$proxy = new BlueprintProxy();

// register all of your routes
$proxy->getRouter()
    ->get('/', 'hello world')
    ->get('about', new HttpResponse(HttpStatusCode::OK, 'foo'))
    ->post('post', function() {
        return 'hello world';
    })
    ->put('users/{id}', function(IHttpRequest $request, array $parameters) {
        return new HttpResponse(HttpStatusCode::OK, $parameters['id']);
    });

// send a response
$proxy->sendResponse();

$server = new BlueprintServer('localhost', 9000, '/path/to/blueprint.php');
$server->start();

$server->stop();