Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

What Are Laravel Exceptions?
Apr 18, 2016 @ 12:25:35

In a new tutorial posted on the TutsPlus.com site they get into some detail about what exceptions are in Laravel-based applications, when to use them and how to make your own.

As a PHP developer, you may use exceptions, because they allow you to notice when something has gone wrong or the user has acted in an unusual way (such as division by zero). Without exceptions, your application would end up presenting unwanted errors and being much more difficult to debug. It is also important that you halt execution immediately and take another course of action.

Exceptions are really simple, and they will make your development progress easier. When you learn how to use exceptions, this will be a usual part of your development.

They start by explaining what exceptions are (in the strictest sense, a definition from Martin Fowler) and an example of how one is caught in PHP. They briefly talk about when to use exceptions and how they're implemented in Laravel. The post finishes with a look at creating your own exception types and where to place them in your application. They also make the suggestion of using the Assertion package to verify data and catch the AssertionFailedException if there's an issue.

tagged: laravel exception example tutorial overview usage

Link: http://code.tutsplus.com/tutorials/what-are-laravel-exceptions--cms-25816