Closed lamoni closed 9 years ago
have you tried in your router do
$soundcloud = $this->app->make('Soundcloud'); // this is the service name
with the FQCN you are asking the container to build the Soundcloud class, that in fact exists (and have constructor dependencies). I believe, that since the dependencies have a default value of null
that's what the Laravel Container is passing while instantiating you request. and that will throw the exception on the Auth class (since the validation of those values are made there in the Auth class).
and after that, you are also calling getAuthUrl()
method that does not even exist in the Soundcloud\Soundcloud
class, but on a sub class, called Soundcloud\SoundcloudFacade
right now, i've no access to my laravel 5 development env, but can you provide me a detailed stack trace for further investigation?
Thanks for the quick reply,
Here's my updated route from routes.php:
Route::get('/test', function() {
$soundcloud = $this->app->make('Soundcloud');
echo $soundcloud->getAuthUrl();
});
services.php
'soundcloud' => [
'client_id' => 'MYCLIENTIDHERE',
'client_secret' => 'MYCLIENTSECRETHERE',
'callback_url' => 'MYCALLBACKURLHERE'
],
Stacktrace:
ReflectionException in Container.php line 776:
Class Soundcloud does not exist
in Container.php line 776
at ReflectionClass->__construct('Soundcloud') in Container.php line 776
at Container->build('Soundcloud', array()) in Container.php line 656
at Container->make('Soundcloud', array()) in Application.php line 644
at Application->make('Soundcloud') in routes.php line 95
at RouteServiceProvider->{closure}()
at call_user_func_array(object(Closure), array()) in Route.php line 157
at Route->runCallable(object(Request)) in Route.php line 129
at Route->run(object(Request)) in Router.php line 701
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Router.php line 703
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 670
at Router->dispatchToRoute(object(Request)) in Router.php line 628
at Router->dispatch(object(Request)) in Kernel.php line 214
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 141
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in VerifyCsrfToken.php line 43
at VerifyCsrfToken->handle(object(Request), object(Closure)) in VerifyCsrfToken.php line 17
at VerifyCsrfToken->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in ShareErrorsFromSession.php line 55
at ShareErrorsFromSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in StartSession.php line 61
at StartSession->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in AddQueuedCookiesToResponse.php line 36
at AddQueuedCookiesToResponse->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in EncryptCookies.php line 40
at EncryptCookies->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request)) in CheckForMaintenanceMode.php line 42
at CheckForMaintenanceMode->handle(object(Request), object(Closure)) in Pipeline.php line 125
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 101
at Pipeline->then(object(Closure)) in Kernel.php line 115
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 84
at Kernel->handle(object(Request)) in index.php line 53
Also made sure I've dumpautoloaded:
lamoni@dev:/var/www$ composer dumpautoload -o
Generating optimized autoload files
app.php
'providers' => [
...
'Njasm\Laravel\Soundcloud\SoundcloudProvider',
];
composer.json
"require": {
...
"njasm/laravel5-soundcloud": "dev-master"
},
do you also have added the soundcloud provider to your app/config/app.php
?
'providers' => array(
//...
'Njasm\Laravel\Soundcloud\SoundcloudProvider', // last line
)
@njasm Sorry, modified my other comment to show the app.php provider configuration
I got it working but had to remove the deferring from the ServiceProvider and clear-compiled with php artisan.
SoundcloudProvider.php
protected $defer = false;
lamoni@dev:/var/www$ php artisan clear-compiled
It then works, but I'd like to get the deferring working. According to Laravel docs, we need a public function called "provides()". Could that be the cause?
To defer the loading of a provider, set the defer property to true and define a provides method. The provides method returns the service container bindings that the provider registers:
Looks like the provides() method fixed it. I'll send a pull request. Thanks!
for future reference: while debugging Providers, we should not forget to erase laravel's cache files .. with php artisan clear-compiled
@lamoni thanks for the pull
@njasm Gladly :) great work on this package.
Having a hell of a time getting this to work with Laravel 5,
I've followed the instructions in the README exactly (with the exception of changing my ::make call to include SoundCloud class's namespace so it could correctly resolve), I'm getting this error though:
I've also made sure that my services.php file is up-to-date with my client ID and client Secret.
Any ideas?
Thanks!