下面的代码说明了一切......Laravel 4:从make传递数据到服务提供商
// routes.php
App::make('SimpleGeo',array('test')); <- passing array('test')
// SimpleGeoServiceProvider.php
public function register()
{
$this->app['SimpleGeo'] = $this->app->share(function($app)
{
return new SimpleGeo($what_goes_here);
});
}
// SimpleGeo.php
class SimpleGeo
{
protected $_test;
public function __construct($test) <- need array('test')
{
$this->_test = $test;
}
public function getTest()
{
return $this->_test;
}
}
你好@schmaltz你有问题吗?我有同样的问题,并寻找一个解决方案,因为我的应用程序使用类似的架构,像你的.. – Omranic 2014-02-13 05:40:23