There are two ways to manually trigger a 404 error from a route. First, you may use the abort helper. The abort helper simply throws a SymfonyComponentHttpFoundationExceptionHttpException with the specified status code:
Secondly, you may manually throw an instance of
More information on handling 404 exceptions and using custom responses for these errors may be found in the errors section of the documentation.