相关疑难解决方法(0)

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;
    }
}
Run Code Online (Sandbox Code Playgroud)

laravel laravel-4

6
推荐指数
2
解决办法
6445
查看次数

标签 统计

laravel ×1

laravel-4 ×1