路由
$app
集成了 Hyperf 路由器的所有方法。
<?php
use Hyperf\Nano\Factory\AppFactory;
require_once __DIR__ . '/vendor/autoload.php';
$app = AppFactory::create();
$app->addGroup('/nano', function () use ($app) {
$app->addRoute(['GET', 'POST'], '/{id:\d+}', function($id) {
return '/nano/'.$id;
});
$app->put('/{name:.+}', function($name) {
return '/nano/'.$name;
});
});
$app->run();