Phil
Phil

Reputation: 2236

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,    

Upvotes: 20

Views: 17059

Answers (2)

Shota
Shota

Reputation: 7330

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

Upvotes: 4

Mihail Burduja
Mihail Burduja

Reputation: 3256

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

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

Laravel 4.2:

$debug = Config::get('app.debug');

Upvotes: 38

Related Questions