<?php /* * This file is part of the Caffeine Experiment. * * (c) Tigran Azatyan <*****@*****.**> * * This source file is subject to the MIT license that is bundled * with this source code in the file LICENSE. */ namespace App; require './vendor/autoload.php'; use React\Espresso\Application; use React\Espresso\Stack; use Silex\Provider\TwigServiceProvider; $app = new Application(); $app->register(new TwigServiceProvider(), ['twig.path' => __DIR__ . '/views']); $app->get('/', function ($request, $response) use($app) { $response->writeHead(200, ['Content-Type' => 'text/html']); $body = $app['twig']->render('home.html.twig'); $response->end($body); }); $app->error(function ($request, $response) { $response->writeHead(404, ['Content-Type' => 'text/html']); $response->end('Error 404'); }); $stack = new Stack($app); $stack->listen(1337);