PHP code example of aheart / espresso

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

    

aheart / espresso example snippets


$app = new React\Espresso\Application();

$app->get('/', function ($request, $response) {
    return 'Hello World';
});

$app->get('/hello/{name}', function($name) use($app) {
    return 'Hello '.$app->escape($name);
});

$app->error(function (\Exception $e, $code) use ($app) {
	return 'Page not found';
});

$stack = new React\Espresso\Stack($app);
$stack->listen(1337);