我要定制的环境检测。我知道现有的Laravel环境检测是如何工作的,但我想要一种更有活力的方法。我希望导出-- Ubuntu中的一个变量,建议它是“开发”或“生产”,而不是使用主机名和IP地址。
任何帮助都会很好,谢谢。
发布于 2014-08-15 11:04:32
我在我的项目中所做的就是创建一个文件“app/bootstrap/Environ.php”
environment.php
<?php
//Get the environment
$environment = getenv('ENV');
//Check if the environment has been set
if(is_string($environment) && ($environment != '')){
//Return the environment
return $environment;
}else{
//On default return production environment
return 'production';
}然后在"app/bootstrap/start.php“中
start.php
$env = $app->detectEnvironment(function()
{
//Return the environment we're currently using
return require __DIR__.'/environment.php';
});对我来说很合适。
https://stackoverflow.com/questions/25325305
复制相似问题