I'm having problems getting routes with parameters to work in Slim 3 RC.
$app->get('/hello/:name', function($req, $res, $args) {
echo "Hello {$name}";
});
Visiting /hello/joe
results in 404.
Other routes work fine, e.g.:
$app->get('/', HomeAction::class . ":dispatch");
$app->get('/services', ServicesAction::class . ":dispatch");
I am using the built-in PHP server while I am developing. I do not have any .htaccess
file. I have tried the suggested route.php
suggestion and the accepted answer from this question but it does not work. Any suggestions please?
From Slim 3 you need to change :name
in {name}
.
$app->get('/hello/{name}', function ($request, $response, $args) {
return $response->write("Hello " . $args['name']);
});
You can find the documentation here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With