Exceptions in Laravel: Spatie Permission Example

preview_player
Показать описание
I wanted to show you why/how you would create custom Exception classes in Laravel.

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

One more informative video regarding exceptions

shahsawoodshinwari
Автор

I don't know how it is in PHP but as I used to work on a big project in C#, we used the same syntax (like PermissonDoesNotExist) in a place that wasn't so good. Instead of throwing an IF statement and returning "false", we threw an exception and returned "false".

We realized one thing in C#. If you use this syntax in a case that can occur multiple times in a very short time. Then this has an extreme impact on performance. How this behaves in PHP, I have no idea. But you should only use exceptions if a really serious error has occurred and if it cannot be triggered at very short intervals.
Don't get me wrong. Exceptions are important and good, but I just wanted to show that it's not called an 'exception' for nothing.

Very informative video anyway, thanks!

Bruni
Автор

listen please make a video on spatie pkg full video your teaching method is very good

onlinetechnology
Автор

Why would you want to use try / catch block when checking permissions which is internal logic? It doesn't make sense. Or is this only for demonstrational purposes? I would also strongly advise against returning false or null in catch block - if there be some error it will just faill silently.

martinsbergmanis
Автор

i jst love e's forwarded 2 my telegram channel ;)

kafeshop