Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

laravel how to read app/config/app.php debug variable

How do I access the debug variable in app/config/app.php from my controller to see if I am in debug mode?

<?php                                                                                                                
                                                                                                                     |
  /*                                                                                                                 |        if ( $this->user->id )
  |--------------------------------------------------------------------------                                        |        {
  | Application Debug Mode                                                                                           |            // Save roles. Handles updating.
  |--------------------------------------------------------------------------                                        |            $this->user->saveRoles(Input::get( 'roles' ));
  |                                                                                                                  |
  | When your application is in debug mode, detailed error messages with                                             |            // Redirect to the new user page
  | stack traces will be shown on every error that occurs within your                                                |            return Redirect::to('admin/users/'.$this->user->id)->with('success', Lang::get('admin/users/messages.cre
  | application. If disabled, a simple generic error page is shown.                                                  |ate.success'));
  |                                                                                                                  |        }
  */                                                                                                                 |  else
                                                                                                                     |  {
  'debug' => true,    
like image 371
Phil Avatar asked Aug 24 '15 18:08

Phil


2 Answers

You can use the helper function config (Laravel 5+).

$debug = config('app.debug');

Laravel 4.2:

$debug = Config::get('app.debug');
like image 166
Mihail Burduja Avatar answered Oct 16 '22 05:10

Mihail Burduja


This question already has right answer, I just wanted to add that doing it with environmental variables is a better option:

'debug' => env('APP_DEBUG', false),

In .env file:

APP_ENV=local
like image 21
Shota Avatar answered Oct 16 '22 07:10

Shota