laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.52k stars 11.02k forks source link

[5.3] Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager #15304

Closed ghost closed 8 years ago

ghost commented 8 years ago

When I use pda/pheanstalk queue (3.0.x or 3.1.x ) and queued event listeners, which sends slack Notifications, I receive this error in bugsnag.

Illuminate\Contracts\Container\BindingResolutionExceptionvendor/laravel/framework/src/Illuminate/Container/Container.php:835
Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager

And I cant find place which is causing this error.

Full stacktrace:

Illuminate\Contracts\Container\BindingResolutionException Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager 
    vendor/laravel/framework/src/Illuminate/Container/Container.php:835 Illuminate\Container\Container::resolveNonClass
    vendor/laravel/framework/src/Illuminate/Container/Container.php:802 Illuminate\Container\Container::getDependencies
    vendor/laravel/framework/src/Illuminate/Container/Container.php:773 Illuminate\Container\Container::build
    vendor/laravel/framework/src/Illuminate/Container/Container.php:629 Illuminate\Container\Container::make
    vendor/laravel/framework/src/Illuminate/Foundation/Application.php:699 Illuminate\Foundation\Application::make
    vendor/laravel/framework/src/Illuminate/Container/Container.php:573 Illuminate\Container\Container::addDependencyForCallParameter
    vendor/laravel/framework/src/Illuminate/Container/Container.php:533 Illuminate\Container\Container::getMethodDependencies
    vendor/laravel/framework/src/Illuminate/Container/Container.php:505 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:94 Illuminate\Bus\Dispatcher::Illuminate\Bus\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:151 Illuminate\Pipeline\Pipeline::Illuminate\Pipeline\{closure}
    vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:104 Illuminate\Pipeline\Pipeline::then
    vendor/laravel/framework/src/Illuminate/Bus/Dispatcher.php:98 Illuminate\Bus\Dispatcher::dispatchNow
    vendor/laravel/framework/src/Illuminate/Queue/CallQueuedHandler.php:47 Illuminate\Queue\CallQueuedHandler::call
    vendor/laravel/framework/src/Illuminate/Queue/Jobs/Job.php:72 Illuminate\Queue\Jobs\Job::fire
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:207 Illuminate\Queue\Worker::process
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:160 Illuminate\Queue\Worker::runNextJob
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:111 Illuminate\Queue\Worker::runNextJobForDaemon
    vendor/laravel/framework/src/Illuminate/Queue/Worker.php:74 Illuminate\Queue\Worker::daemon
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:97 Illuminate\Queue\Console\WorkCommand::runWorker
    vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php:78 Illuminate\Queue\Console\WorkCommand::fire
    [internal] call_user_func_array
    vendor/laravel/framework/src/Illuminate/Container/Container.php:507 Illuminate\Container\Container::call
    vendor/laravel/framework/src/Illuminate/Console/Command.php:169 Illuminate\Console\Command::execute
    vendor/symfony/console/Command/Command.php:256 Symfony\Component\Console\Command\Command::run
    vendor/laravel/framework/src/Illuminate/Console/Command.php:155 Illuminate\Console\Command::run
    vendor/symfony/console/Application.php:818 Symfony\Component\Console\Application::doRunCommand
    vendor/symfony/console/Application.php:186 Symfony\Component\Console\Application::doRun
    vendor/symfony/console/Application.php:117 Symfony\Component\Console\Application::run
    vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:122 Illuminate\Foundation\Console\Kernel::handle
    artisan:35 [main]

Steps To Reproduce:

Fire an event, which has queued event listener that uses new 5.3 introduced notification class and sends slack notification.

GrahamCampbell commented 8 years ago

What does your code look like please?

crynobone commented 8 years ago

This might be a case of upgrading from 5.2 to 5.3 where you need to include Illuminate\Notifications\ NotificationServiceProvider to config/app.php.

progamer commented 7 years ago

I have the same issue and Illuminate\Notifications\NotificationServiceProvider included in config/app.php Any one solved this issue ?

ghost commented 7 years ago

@progamer still have this issue on my production server. Can't find reason why I'm having that error.

progamer commented 7 years ago

@crynobone NotificationServiceProvider already included in config/app.php , @ddctd143 did you solve it on your development env ?

ghost commented 7 years ago

@progamer Prod env uses beanstalk queue, development uses sync mode ( no queue ). It is only difference between those environments. I tried to switch prod env to sync queue driver, nothing changes.

Yes, NotificationServiceProvider is included, and I'm using it alot in my app. Prod environment successfully sends slack notifications, but error still occurs in bugsnag. It is very annoying to receive 50-60 errors each day.

Example:

screen shot 2016-12-07 at 22 24 45
progamer commented 7 years ago

@ddctd143 my happened with pusher, but the source is the same, i don't think its related to sync/async mode, because i have it on laravel notifications the error shown in both cases when notification is queued or triggered directly

` [2016-12-07 20:29:28] local.ERROR: Illuminate\Contracts\Container\BindingResolutionException: Unresolvable dependency resolving [Parameter #0 [ $auth_key ]] in class Pusher in /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Container/Container.php:850 Stack trace:

0 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Container/Container.php(817): Illuminate\Container\Container->resolveNonClass(Object(ReflectionParameter))

1 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Container/Container.php(788): Illuminate\Container\Container->getDependencies(Array, Array)

2 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Container/Container.php(644): Illuminate\Container\Container->build('pusher', Array)

3 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(709): Illuminate\Container\Container->make('pusher', Array)

4 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(233): Illuminate\Foundation\Application->make('pusher')

5 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Support/Manager.php(63): Illuminate\Notifications\ChannelManager->createDriver('pusher')

6 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(79): Illuminate\Support\Manager->driver('pusher')

7 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Notifications/ChannelManager.php(43): Illuminate\Notifications\ChannelManager->sendNow(Object(Illuminate\Database\Eloquent\Collection), Object(App\Notifications\CommentOnYourPost))

8 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(237): Illuminate\Notifications\ChannelManager->send(Object(Illuminate\Database\Eloquent\Collection), Object(App\Notifications\CommentOnYourPost))

9 /Users/ezents/Documents/you-know-web/app/Services/NotificationService.php(31): Illuminate\Support\Facades\Facade::__callStatic('send', Array)

10 /Users/ezents/Documents/you-know-web/app/Observers/CommentObserver.php(37): App\Services\NotificationService->notifyNewCommentAdded(Object(App\Comment))

11 [internal function]: App\Observers\CommentObserver->updating(Object(App\Comment))

12 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(348): call_user_func_array(Array, Array)

13 [internal function]: Illuminate\Events\Dispatcher->Illuminate\Events{closure}(Object(App\Comment))

14 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(221): call_user_func_array(Object(Closure), Array)

15 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(164): Illuminate\Events\Dispatcher->fire('eloquent.updati...', Array, true)

16 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1664): Illuminate\Events\Dispatcher->until('eloquent.updati...', Object(App\Comment))

17 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1525): Illuminate\Database\Eloquent\Model->fireModelEvent('eloquent.updati...')

18 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(1464): Illuminate\Database\Eloquent\Model->performUpdate(Object(Illuminate\Database\Eloquent\Builder), Array)

19 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/HasOneOrMany.php(225): Illuminate\Database\Eloquent\Model->save()

20 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Relations/MorphOneOrMany.php(95): Illuminate\Database\Eloquent\Relations\HasOneOrMany->save(Object(App\Comment))

21 /Users/ezents/Documents/you-know-web/app/Http/Controllers/Front/CommentsController.php(60): Illuminate\Database\Eloquent\Relations\MorphOneOrMany->save(Object(App\Comment))

22 [internal function]: App\Http\Controllers\Front\CommentsController->store(Object(App\Http\Requests\StoreComment), Object(App\Post))

23 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(55): call_user_func_array(Array, Array)

24 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(44): Illuminate\Routing\Controller->callAction('store', Array)

25 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Route.php(189): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(App\Http\Controllers\Front\CommentsController), 'store')

26 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Route.php(144): Illuminate\Routing\Route->runController()

27 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(642): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))

28 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Routing\Router->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

29 /Users/ezents/Documents/you-know-web/vendor/xinax/laravel-gettext/src/Xinax/LaravelGettext/Middleware/GettextMiddleware.php(27): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

30 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Xinax\LaravelGettext\Middleware\GettextMiddleware->handle(Object(Illuminate\Http\Request), Object(Closure))

31 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

32 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php(41): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

33 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Routing\Middleware\SubstituteBindings->handle(Object(Illuminate\Http\Request), Object(Closure))

34 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

35 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Auth/Middleware/Authenticate.php(43): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

36 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Auth\Middleware\Authenticate->handle(Object(Illuminate\Http\Request), Object(Closure))

37 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

38 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php(65): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

39 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle(Object(Illuminate\Http\Request), Object(Closure))

40 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

41 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php(49): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

42 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\View\Middleware\ShareErrorsFromSession->handle(Object(Illuminate\Http\Request), Object(Closure))

43 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

44 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php(64): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

45 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Session\Middleware\StartSession->handle(Object(Illuminate\Http\Request), Object(Closure))

46 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

47 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php(37): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

48 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle(Object(Illuminate\Http\Request), Object(Closure))

49 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

50 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php(59): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

51 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Cookie\Middleware\EncryptCookies->handle(Object(Illuminate\Http\Request), Object(Closure))

52 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

53 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

54 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(644): Illuminate\Pipeline\Pipeline->then(Object(Closure))

55 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(618): Illuminate\Routing\Router->runRouteWithinStack(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request))

56 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Router.php(596): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))

57 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(268): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))

58 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(53): Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http{closure}(Object(Illuminate\Http\Request))

59 /Users/ezents/Documents/you-know-web/vendor/barryvdh/laravel-debugbar/src/Middleware/Debugbar.php(51): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

60 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Barryvdh\Debugbar\Middleware\Debugbar->handle(Object(Illuminate\Http\Request), Object(Closure))

61 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

62 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/CheckForMaintenanceMode.php(46): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

63 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(137): Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode->handle(Object(Illuminate\Http\Request), Object(Closure))

64 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(33): Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(Object(Illuminate\Http\Request))

65 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(104): Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Object(Illuminate\Http\Request))

66 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(150): Illuminate\Pipeline\Pipeline->then(Object(Closure))

67 /Users/ezents/Documents/you-know-web/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(117): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))

68 /Users/ezents/Documents/you-know-web/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))

69 {main}

`

ghost commented 7 years ago

@progamer Do you have fresh installation of laravel 5.3 or you upgraded from 5.2 to 5.3.x as I did ?

progamer commented 7 years ago

@ddctd143 no upgraded , but in early stage of development.

danielsdeboer commented 7 years ago

I got this error after an in place upgrade where I forgot to restart my queue workers. Restarting the queue workers fixed it.

avks commented 7 years ago

Anyone has solved the issue? Having the same problem on a fresh Lumen 5.4 installation.

aldee07 commented 7 years ago

@danielsdeboer Thanks mate! This works for me. Do you have any clue why?

dlwatersuk commented 7 years ago

@aldee07 queue workers seem to bootstrap and cache the entire application so probably that they held outdated versions of code.

ghost commented 7 years ago

Thats true. You should restart queue after each deployment. Example:

...
cd /home/forge/your-site.com
git pull origin master
composer install --no-interaction --no-dev --prefer-dist
php artisan migrate --force
php artisan cache:clear
php artisan queue:restart # <- this line will prevent from error.
...
gh0sthx commented 6 years ago

Having the same problem when i use factory(App\Post::class,20)->create(); 。who can help me ??

gh0sthx commented 6 years ago

ErrorMessage Illuminate\Contracts\Container\BindingResolutionException with message 'Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\Support\Manager'

mingalevme commented 6 years ago

@Paladinhanxiao, in my case the error was related to unconfigured Laravel Scout, if you are using Scout, try to remove Laravel\Scout\Searchable-trait from the model and re-run seeding.

yosifeldman commented 6 years ago

Same error "Unresolvable dependency resolving [Parameter #0 [ <required> $app ]] in class Illuminate\\Support\\Manager"

In my case, fixed it by removing the class parameter from the Controller constructor, which was tried to be loaded by DependencyInjection.

The issue was that the class required some parameters passed to it's constructor, so the DependencyInjection failed to create an instance. Laravel/Lumen 5.6

class MyController extends Controller {
    public function __construct(Some $obj) {
.....

So, in the above code, the "Some" class requires parameters in constructor, which causes for the issue.

lidrissi commented 5 years ago

This might be a case of upgrading from 5.2 to 5.3 where you need to include Illuminate\Notifications\ NotificationServiceProvider to config/app.php.

that works for me (y)

a-waris commented 3 years ago

Faced this problem upgrading from lumen 5.8 to 6:

I was able to solve this by making the parameter matching with the one defined in the route In my case the router parameter "uuid" was being expected as "$emailUuid", so changing it to "$uuid" resolved that for me.
$router->get('/emails/{uuid}', 'EmailController@show');

Before: ` /**

After:
` /**