简体   繁体   English

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

[英]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.

相关问题 Laravel config/app.php 和.env 文件中的应用程序环境变量 - Laravel Application Environment variable in config/app.php and .env file 如何阅读config / app.php中定义的“电子邮件”选项? - How to read the 'Email' options defined in config/app.php? 将会话连接到Laravel 5.2中的config / app.php设置 - Concatenate session to config/app.php setting in Laravel 5.2 Laravel 5中config / app.php提供者数组中:: class的含义是什么 - What is the meaning of ::class in config/app.php provider array in Laravel 5 如何从 Laravel 的 config/app.php 中获取客户端 ip 地址? - How to get the client ip address from Laravel's config/app.php? 我们如何从数据库或laravel 5 config文件夹中app.php的其他文件中访问数据 - how do we access data from database or other files in app.php of the config folder in laravel 5 如何修复config / app.php Laravel中的提供程序,它始终未找到错误 - How to fix provider in config/app.php Laravel that's starting not found error Laravel 如何从 config\app.php =&gt; 提供者中自动加载所有提供者类 - How Laravel auto load all provider classes from config\app.php => providers Laravel-如何在app.php中设置语言环境 - Laravel - how to set the locale language in app.php 如何保护app.php加密密钥? (Laravel 5) - How to secure app.php encryption key? (Laravel 5)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM