Laravel5.4 不同环境下 env 文件设置
来源:互联网 发布:软件自动升级方案 编辑:程序博客网 时间:2024/06/15 13:01
Laravel5.4现在支持不同环境下env
文件设置(好像是L5.4最新支持的吧,记不清楚了,也有可能L5.2-5.3就已经支持了),可以针对不同环境(development, staging, production)设置env文件为:
development: .env.developmentstaging: .env.stagingproduction: .env.production
根据不同环境服务器设置系统变量(可根据phpinfo()
查看APP_ENV
环境变量是否OK):
development: APP_ENV=developmentstaging: APP_ENV=stagingproduction: APP_ENV=production
这样,项目根目录下就会有根据不同环境对应的.env.xxx
文件,放入版本控制,本地的环境对应.env
不需要放入版本控制。
原理可看laravel的源码:
namespace Illuminate\Foundation\Bootstrap;use Dotenv\Dotenv;use Dotenv\Exception\InvalidPathException;use Symfony\Component\Console\Input\ArgvInput;use Illuminate\Contracts\Foundation\Application;class LoadEnvironmentVariables{ /** * Bootstrap the given application. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ public function bootstrap(Application $app) { if ($app->configurationIsCached()) { return; } $this->checkForSpecificEnvironmentFile($app); try { (new Dotenv($app->environmentPath(), $app->environmentFile()))->load(); } catch (InvalidPathException $e) { // } } /** * Detect if a custom environment file matching the APP_ENV exists. * * @param \Illuminate\Contracts\Foundation\Application $app * @return void */ protected function checkForSpecificEnvironmentFile($app) { if (php_sapi_name() == 'cli' && with($input = new ArgvInput)->hasParameterOption('--env')) { $this->setEnvironmentFilePath( $app, $app->environmentFile().'.'.$input->getParameterOption('--env') ); } if (! env('APP_ENV')) { return; } $this->setEnvironmentFilePath( $app, $app->environmentFile().'.'.env('APP_ENV') ); }
阅读全文
0 0
- Laravel5.4 不同环境下 env 文件设置
- Laravel5.4 不同环境下 env 文件设置
- ubuntu LAMP 下laravel5.0 运行环境设置
- laravel5.5 路由分割成不同文件
- xampp 配置laravel5.4环境
- laravel5.4 服务提供者设置
- 磕磕绊绊配置linux 下 laravel5.1 环境
- windows下laravel5.5环境安装配置
- orcad 快捷键设置 (修改env文件)
- Laravel5.4 下nginx配置
- CentOs7.3下搭建LAMP环境(Apache2.4 + Mysql5.7 + PHP5.6 + Laravel5.2)
- VNC在不同桌面环境下的设置
- Wampserver+Composer搭建Laravel5.4环境
- laravel5.4+vue+element+vux环境搭建
- lamp+laravel5.4搭建项目环境
- linux下的环境文件设置说明
- windows系统下如何设置laravel5的任务
- c/vc++ 环境下不同的文件长度获取方法
- Android中Activity生命周期浅析
- SQLite学习手册(在线备份)
- android 抛弃Mvc ,初尝 Mvp 模式
- HDU 2586 How far away (LCA模板题 树上点对间距离)
- nginx配置静态资源,访问返回403
- Laravel5.4 不同环境下 env 文件设置
- 暑期ssh框架之struts2学习笔记三
- 漫聊android适配动态权限机制
- 2017 Multi-University Training Contest
- 迭代加深搜索--IDA*--uva11212 Editing a book
- c语言打印九九乘法表
- No qualifying bean of type 'com.yubai.el.ELConfig' available
- Java构建工具:Maven与Gradle的对比
- 求字符串长度