How can I throw a 404 error code when a route does not exist?
In phalcon after you set up your routing information – is there a way to check to see if a route coming in (from the user) matches any of the routes in your routes list? Then, if the route does not exist, throw a 404 error.
You can use something like this:
If you are using the Micro component you can use this:
Of course you can use the suggestions that others posted regarding the .htaccess file, but above is how you do it in Phalcon without touching anything else.
There is also a new feature coming down the pipeline, regarding a default error handler that would process errors in Phalcon (or overriden if necessary).
Credits to Nesbert for the gist