[英]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? 如何从我的控制器访问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,
You can use the helper function config (Laravel 5+). 您可以使用辅助功能配置(Laravel 5+)。
$debug = config('app.debug');
Laravel 4.2: Laravel 4.2:
$debug = Config::get('app.debug');
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: 在.env文件中:
APP_ENV=local
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.