در حال بارگذاری ...

Baseline Artisan errors in 5.50:00

Now, you'll see I have two tabs here, one for a Laravel 5.6 installation, and another for Laravel 5.5. Let's start in 5.5. Now, as you know, within your routes folder, there is a console section to quickly declare any console commands using a callback function. Alternatively, you can define them as dedicated classes within your console directory. Anyhow, here you can see it's just echoing out an inspiring quote. So if we give this a run, php artisan inspire, you get a random quote out of about 20. Now, what if an error or an exception is thrown along the way, like this? Okay, so if we give that another run, yeah, now we do get the exception, but that's about

Improved console exceptions in 5.60:36

Now, what if an error or an exception is thrown along the way, like this? Okay, so if we give that another run, yeah, now we do get the exception, but that's about it. You get the line number and the error, and that's it. Let's see how it's different now in 5.6, thanks to a library called Collision. So what I'll do is copy this file, open this up now in Laravel 5.6, we'll go once again to routes/console, and paste it in. Okay, now if we give this a run, once again, remember in 5.5, this is what we got, in 5.6, we now get much better output. And once again, this is due to a library called Collision, which you can review here,

Collision library overview1:19

we now get much better output. And once again, this is due to a library called Collision, which you can review here, you can even add it to your own projects if you wish. Now I believe you can actually even use it in PHPUnit, I'm not sure, because I think in Laravel, it's actually disabled in the testing environment, so it will not work for your PHPUnit tests. So I think this is mostly limited to your console testing, but yeah, what a difference. Here's what you had in 5.5, and here's what you have in 5.6. We have the full exception trace, and of course a visual of exactly where the exception or error occurred.

We have the full exception trace, and of course a visual of exactly where the exception or error occurred.

دوست دارید گاهی خبرهای Laracasts را ایمیل کنیم؟