Hi Ive got a class that is has a service provider ( Ive renamed the Class to hidden in this sample.)
$this->app['hidden'] = $this->app->share(function($app){
$version = $app['config']->get('hidden/client::version');
$manifestPath = $app['config']->get('hidden/client::manifest_path');
$baseUrl = $app['config']->get('hidden/client::base_url');
return new Hidden($version,$manifestPath,$baseUrl);
});
Now this is a Guzzle client so the version and Guzzle service descriptors are loaded now the web service dose not use OAuth 2 so what Im doing in a Route::get closure I call the login method and than save the token to the instance but the next time I ask the container for the class I get a class with none of the properties set
Route::get('hauth', function() use ($app) {
$response = $app['hidden']->api()->login(['username' => 'jason', 'password' => 'password']);
$app['hidden']->setToken($response['token']);
});
Route::get('someroute',function() use ($app) {
$app['hidden']->getToken();
//this is null the token is no longer set.
});
now the next time I ask for $app['hidden'] the token property is not set now Ive tried to use share or singleton but none seem to work
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community