Laravel 4: Passing data from make to the service provider

后端 未结 2 433
梦如初夏
梦如初夏 2020-12-18 03:44

The code below says it all...

// routes.php
App::make(\'SimpleGeo\',array(\'test\')); <- passing array(\'test\')

// SimpleGeoServiceProvider.php
pu         


        
2条回答
  •  暖寄归人
    2020-12-18 04:08

    You can try to bind the class with the parameters directly into your app container, like

    app->bind('SimpleGeo', function($app, $parameters)
            {
                return new SimpleGeo($parameters);
            });
        }
    }
    

    leaving untouched your SimpleGeo.php. You can test it in your routes.php

    $test = App::make('SimpleGeo', array('test'));
    
    var_dump ($test);
    

提交回复
热议问题