捕获生产环境中的所有应用程序异常和PHP错误

How can I catch all application exceptions and PHP errors in production environment?

I am using a custom MVC framework, and I have a entry point where my MVC framework starts. So I already wrap this entry point with a general:

 try{
    //start point of mvc framework that load main class 
    //that manage request, response, route etc
 }catch(Exception $e) {
    //return response 404 to client if something goes wrong
 }

Is this enough? What about PHP errors?

It's a production environment so I don't the users to see the errors, but I want to log all for debugging. Is there an opensource PHP class that log errors in a elegant way that I can inspire from?

Nope, an exception handler is not enough. You should also transform php notices/errors/warnings into exceptions so that you can catch them as well, I have an example here: http://codehackit.blogspot.com/2012/01/php-errorswarningsnotices-to-exceptions.html Unfortunately most of PHPs built in functions still don't throw exceptions but these couple lines fix that ;)