如何读取app/config/app.php的调试变量


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

我如何从控制器访问app/config/app.php中的调试变量以查看我是否处于调试模式?

<?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,    

您可以使用助手函数config (Laravel 5+)

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

Laravel 4.2:

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

这个问题已经有了正确的答案,我只是想补充一下,用环境变量来做是一个更好的选择:

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

在。env文件中:

APP_ENV=local