laravel如何阅读app / config / app.php调试变量

时间:2015-08-24 18:59:00

标签: php laravel laravel-4 laravel-5

如何从我的控制器访问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,    

1 个答案:

答案 0 :(得分:29)

您可以使用辅助功能配置(Laravel 5 +)。

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

Laravel 4.2:

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