Skip to content
New issue

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

trigger 404 #83

Closed
gandaldf opened this issue Mar 21, 2013 · 3 comments
Closed

trigger 404 #83

gandaldf opened this issue Mar 21, 2013 · 3 comments

Comments

@gandaldf
Copy link

I don't know if this is the right section to post a question.. but I would like to know how to trigger 404 error programmatically...
I know that this:

respond('404', function ($request) {
$page = $request->uri();
echo "Oops, it looks like $page doesn't exist..\n";
});

will be triggered when a route doesn't exists.. and this works well! but I would like to know how to manually call "something" in way to trigger the above respond.
thank you

@chriso
Copy link
Contributor

chriso commented Mar 22, 2013

The only way to do it (at this stage) is to define your 404 handler as a standalone closure

<?php

$notfound = function ($request, $response) {
    //Handle 404
};

respond('/some_route', function ($request, $repsonse) use ($not_found) {
    if (should_404) {
        return $not_found($request, $response);
    }
    // ...
});

respond('404', $notfound);

@Rican7
Copy link
Member

Rican7 commented Mar 22, 2013

+1 @chriso
That may change soon, though. ;)

@gandaldf
Copy link
Author

Ok! thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants