Using the built-in webserver on travis and realized that it won’t call ‘public/index.php’ when the route contains a file extension… Imagine the following route (fastroute, expressive 3):
return function (Application $app, MiddlewareFactory $factory, ContainerInterface $container) : void {
//$app->get('/', App\Handler\HomePageHandler::class, 'home');
$app->get('/api/order/{order_id:\d+}.{format:json|xml}', new class() implements RequestHandlerInterface {
public function handle(ServerRequestInterface $request): ResponseInterface
{
return (new JsonResponse([
'format' => $request->getAttribute('format'),
'order_id' => $request->getAttribute('order_id')
]))->withStatus(200);
}
}, 'order-route');
};
Start the built-in server (composer serve
or php -S 0.0.0:1234 -t public/
) and try to reach http://localhost/api/order/12.json
as an example… You’ll probably have a 404 (tested with PHP7.1, 7.2 latests)… the built-in webserver does not even call the public/index.php
…
Using:
$ php -S 0.0.0.0:1234 -t public/ $(pwd)/public/index.php
will do the trick, but was curious if someone had found a better way to do it ?