We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi, I am new to use this awesome library. I am having bit trouble to find an example of http 404 request. How do I handle 404 requests?
The text was updated successfully, but these errors were encountered:
You simply check if there is any returned route. If nothing is returned, its 404 not found
awlad [email protected] 於 2015年11月10日 星期二寫道:
Hi, I am new to use this awesome library. I am having bit trouble to find an example of http 404 request. How do I handle 404 requests? — Reply to this email directly or view it on GitHub #101.
— Reply to this email directly or view it on GitHub #101.
Sorry, something went wrong.
If any above route not match then i want to render a view for 404 with a controller.
use Pux\RouteExecutor; $mux = new Pux\Mux;
class ProductController { public function listAction() { return 'product list'; } public function itemAction($id) { return "product $id"; } } $mux = new Pux\Mux; //var_dump($mux); $mux->any('/product', ['Module\controllers\EmployeesController','index']); $mux->get('/product/:id', ['ProductController','itemAction'] , [ 'require' => [ 'id' => '\d+', ], 'default' => [ 'id' => '1', ] ]); // not match above pattern so 404 $mux->any('.*', ['Module\controllers\WelcomeController','not_found']);
$route = $mux->dispatch($_SERVER['REQUEST_URI']);
I want to rebder welcome#not_found. how can i do that?
echo RouteExecutor::execute($route);
No branches or pull requests
Hi,
I am new to use this awesome library. I am having bit trouble to find an example of http 404 request. How do I handle 404 requests?
The text was updated successfully, but these errors were encountered: