Esempio n. 1
0
<?php

declare (strict_types=1);
namespace Amplify;

use Aerys\Request;
use Aerys\Response;
use function Aerys\router;
use function Aerys\websocket;
$router = router()->route('GET', '/', function (Request $request, Response $response) use($template) {
    $response->send(file_get_contents(__DIR__ . '/templates/page.phtml'));
})->route('GET', '/ws', websocket(new Handler()));
Esempio n. 2
0
<?php

declare (strict_types=1);
namespace Amplify;

use Aerys\Request;
use Aerys\Response;
use function Aerys\router;
use function Aerys\websocket;
$router = router()->route('GET', '/', function (Request $request, Response $response) use($template) {
    $response->send(file_get_contents(__DIR__ . '/templates/page.phtml'));
})->route('GET', '/ws', websocket(new Handler(), ["maxBytesPerMinute" => 1 << 26, "maxFramesPerSecond" => 1000000]))->route('GET', '/stop', function () {
    \Amp\stop();
});
Esempio n. 3
0
<?php

use Aerys\Host;
use Aerys\Router;
use Kelunik\Demo\Chat;
use function Aerys\root;
use function Aerys\websocket;
// route /ws to the websocket endpoint
// you can add more routes to this router
$router = (new Router())->route("GET", "ws", websocket(new Chat()));
// add document root
$root = root(__DIR__ . "/public");
// create virtual host localhost:1337
// requests will first be routed, if no route matches, the server tries to find a file in the document root
// you can add more responders or even multiple document roots to a single host
(new Host())->name("localhost")->expose("*", 1337)->use($router)->use($root);
// $logger is the default Aerys logger which we can just use here to print a note
$logger->info("Open your browser and point it to http://localhost:1337/");