与开发人员一起建立Laravel的最佳方法 [英] Best way to set up Laravel with dev
问题描述
我们刚刚投入工作,决定在所有未来的大型开发项目中使用Laravel.当前,我们正在讨论如何为dev
,testing
和live
设置变量.在我自己的个人项目中,我有类似的东西:
We have just taken the plunge at work and decided to use Laravel on all future large developments. We are currently discussing how we should set variables for dev
, testing
and live
. On my own personal projects I have things like:
if(strpos(__FILE__,'/live/')) {
$currentEnv = 'live';
} else { ... }
然后将变量设置在$currentEnv
的后面. Laravel建议使用
自定义.env
文件位于每个安装目录的根目录(我认为这是版本控制范围之外的内容).
I then set variables off the back of $currentEnv
. Laravel recommends using a
custom .env
file in the root of each of your installs (which I presume means it's out side of version control).
有人可以告诉我每种方法的优缺点吗?
Can someone please tell me the merits and pitfalls of each approach
推荐答案
.env文件是应用程序的设置,可以配置默认环境变量,请检查以下内容示例:
The .env file is the settings of your application you can configure your default environment variable check the following content sample:
APP_ENV=local
APP_DEBUG=true
APP_KEY=AMpO3aZSVYhYKIAQyKch3G0efT3xGrve
DB_HOST=localhost
DB_DATABASE=test
DB_USERNAME=test
DB_PASSWORD=test
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
如果您想在本地工作,可以设置:
If you want to work locally you can set:
APP_ENV=local
APP_DEBUG=true
在生产中,您可以设置:
In Production you can set:
APP_ENV=production
APP_DEBUG=false
这篇关于与开发人员一起建立Laravel的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!