【发布时间】:2014-02-20 18:12:43
【问题描述】:
我正在为 Laravel 4 创建一个包,它将有一个配置文件,用户可以在其中输入包使用的服务的 api 密钥。但是,我无法访问配置值。每当我尝试访问该值时,它总是返回 null。下面是我的代码:
这是服务提供者的注册方法,这里调用了config值:
public function register()
{
$this->app->bind('Datumbox', function($app){
return new \Carwyn\LaravelDatumbox\Lib\DatumboxAPI(
$this->app['config']->get('laravel-datumbox::api_key')
);
});
}
我遇到问题的部分是
$this->app['config']->get('laravel-datumbox::api_key')
我从包的 src/config 目录中的 config.php 文件中调用 api_key 值的部分。
我的配置文件如下:
<?php
return array(
'api_key' => 'apikeyhere',
);
任何帮助将不胜感激。
【问题讨论】:
-
配置文件在哪里?