簡體   English   中英

laravel如何閱讀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,    

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

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

Laravel 4.2:

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

這個問題已經有了正確的答案,我只是想補充一點,用環境變量做這個是一個更好的選擇:

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

在.env文件中:

APP_ENV=local

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM