我创建了app/config/mysite.dev
并在此目录中添加了app.php
和database.php
。然后,我将bootstrap/start.php
中的本地,登台和制作的值更改为引用mysite.dev
。但是,不是检查app/config/mysite.dev/database.php
设置,而是阅读app/config/database.php
。
我觉得我错过了一些重要的步骤。
有什么想法吗?
这是我的bootstrap/start.php
文件:
<?php
/*
|--------------------------------------------------------------------------
| Create The Application
|--------------------------------------------------------------------------
|
| The first thing we will do is create a new Laravel application instance
| which serves as the "glue" for all the components of Laravel, and is
| the IoC container for the system binding all of the various parts.
|
*/
$app = new Illuminate\Foundation\Application;
/*
|--------------------------------------------------------------------------
| Detect The Application Environment
|--------------------------------------------------------------------------
|
| Laravel takes a dead simple approach to your application environments
| so you can just specify a machine name or HTTP host that matches a
| given environment, then we will automatically detect it for you.
|
*/
$env = $app->detectEnvironment(array(
'local' => array('mysite.dev'), // Change this to your local machine hostname.
'staging' => array('mysite.dev'),
'production' => array('mysite.dev'),
));
/*
|--------------------------------------------------------------------------
| Bind Paths
|--------------------------------------------------------------------------
|
| Here we are binding the paths configured in paths.php to the app. You
| should not be changing these here. If you need to change these you
| may do so within the paths.php file and they will be bound here.
|
*/
$app->bindInstallPaths(require __DIR__.'/paths.php');
/*
|--------------------------------------------------------------------------
| Load The Application
|--------------------------------------------------------------------------
|
| Here we will load the Illuminate application. We'll keep this is in a
| separate location so we can isolate the creation of an application
| from the actual running of the application with a given request.
|
*/
$framework = $app['path.base'].'/vendor/laravel/framework/src';
require $framework.'/Illuminate/Foundation/start.php';
/*
|--------------------------------------------------------------------------
| Return The Application
|--------------------------------------------------------------------------
|
| This script returns the application instance. The instance is given to
| the calling script so we can separate the building of the instances
| from the actual running of the application and sending responses.
|
*/
return $app;
答案 0 :(得分:1)
如果你确定你的主机名是'mysite.dev'并且你已将数据库配置放在app/config/mysite.dev/database.php
中,那么你需要以下$app->detectEnvironment
$env = $app->detectEnvironment(array(
'mysite.dev' => array('mysite.dev')
));
我建议将app/config/mysite.dev/database.php
重命名为app/config/dev/database.php
,然后执行以下操作:
$env = $app->detectEnvironment(array(
'dev' => array('mysite.dev')
));
如评论中所述:数组中的键对应于文件夹名称,而值是包含计算机主机名的数组。