Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Anonymous function for notFound in router

As I have my own error handler implemented, I'd like to an option for using anonymous functions in $router->notFound() as it's unnecessary to implement an extra controller. Is there any way to use something like this?

$router->notFound(function() {
    throw new NotFoundException();
});


31.1k
Accepted
answer

Hi @mohahn it's not possible today. As you can see in the source code.

But you can create your own router or better yet create a NFR in github repo

Good luck