PHP MVC Framework Error Exception Handling PHP | Tutorial | PHP Server-Side | Learn PHP

preview_player
Показать описание
Welcome to back to building a MVC PHP framework from start to finish. PHP | Tutorial | PHP Server-Side | Learn PHP Today we look Error handling. Converting PHP error exception into exceptions and create our very exception handler so we can display exceptions according to the environment we are in.

By implementing some design patterns. We will learn about various PHP design patterns and web architect and applying version controlling as we go along.

FOLLOW

Code
Рекомендации по теме
Комментарии
Автор

Thanks for the video, but you didn't show where you called your ErrorHandling class methods? are you set them as exeption handler or how and from wher they should be called?

artemdev
Автор

In the video, the function checks
if (!(error_reporting() && $errno)),

while the project checks
if (error_reporting() & $errno).

Which is the one you actually intended? The one on the video makes more sense, in my opinion. If there is no error reporting and no errno, just return. But if they are passed, then create a new ErrorException, passing all the arguments that are passed into errorHandler().

johnandrew
Автор

The following lines have Resources underlined with a white dashed line in PHPStorm:


1. include

Path 'Resources/Templates/dev.php' not found

2. include


Path not found

Appending dirname(__FILE__) to these strings eliminates the error. Won't this affect the code in any manner?

johnandrew
Автор

And somehow here I don't understand the constructor:

public function __construct()
{

$error = error_get_last();
if($error){
throw new ErrorException($error['message'], -1, $error['type'], $error['file'], $error['line']);
}
});
}

I know error_get_last() gets the last occurred error...well, duh.

But what does register_shutdown_function() do in this specific situation? I know it registers a function for execution on shutdown.

Qn: On shutdown of what object?

johnandrew