How can I check if laravel is connected to the database? I've searched around and I can't find anything that would tell me how this is done.
相关问题
- Laravel Option Select - Default Issue
- Laravel 5.1 MethodNotAllowedHttpException on store
- Laravel - Implicit route model binding with soft d
- laravel : php artisan suddenly stop working
- How to execute MYSQL query in laravel?
相关文章
- laravel create model from custom stub when using p
- send redirect and setting cookie, using laravel 5
- How to send parameters to queues?
- Bcrypt vs Hash in laravel
- Laravel: What's the advantage of using the ass
- How to make public folder as root in Laravel?
- Input file in laravel 5.2?
- What is the difference between Session::set and Se
You can use
It will give you the database name for the connected database, so you can use it to check if your app is connected to it.
But... Laravel will only connect to database once it needs something from database and, at the time of a connection try, if it finds any errors it will raise a
PDOException
, so this is what you can do to redirect your user to a friendly page:Add this to your
app/filters.php
file.In my opinion, you don't really need to check if it is connceted or not, just take the proper action in the exception handling closure.
working :) -
Just added this code to app/filters.php
You can Use the following code :