Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /app/vendor/laravel/framework/src/Illuminate/Container/Container.php:958 #28809

Closed
thejacer87 opened this issue Jun 11, 2019 · 22 comments

Comments

@thejacer87
Copy link

  • Laravel Version: 5.8.21
  • PHP Version: 7.3.4
  • Database Driver & Version: mysql 8.0.16
  • PHPUnit: 8.2.1

likely a duplicate of: #26874, but it was close 6 months ago. but there have been a few comments in the last month or so. perhaps others, like me are getting an issue still.

Description:

i'm getting this error (after adding https://github.com/sebastiaanluca/laravel-auto-morph-map via composer). when i run phpunit i get a few fatal errors. not sure how/why the package would have messed it up. so any help would be great!

PHP Fatal error:  Cannot declare class App\Middleware\FixedStartSession, because the name is already in use in /app/app/Http/Middleware/FixedStartSession.php on line 21

PHP Fatal error:  Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /app/vendor/laravel/framework/src/Illuminate/Container/Container.php:958

Fatal error: Cannot declare class App\Middleware\FixedStartSession, because the name is already in use in /app/app/Http/Middleware/FixedStartSession.php on line 21

Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /app/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 958

Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /app/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 958
@ahinkle
Copy link
Contributor

ahinkle commented Jun 11, 2019

Have you tried composer dump-autoload?

@thejacer87
Copy link
Author

Have you tried composer dump-autoload?

yes. i read that from some other thread/issue whilst in this google rabbit hole. it still doesn't work.

@laurencei
Copy link
Contributor

Have you tried removing the package?

Unfortunately this GitHub area is not a support area for general application issues. This is only for issues/bugs with the framework code itself.

I will be closing your ticket here. Instead please try asking your question on one of the many great community support areas that will likely give you a better answer more quickly:

If you feel I've closed this issue in error, please provide more information about how this is a framework issue, and I'll reopen the ticket.

Thanks in advance.

@carcinocron
Copy link

duplicate: #10808

@aysegeertsma
Copy link

For me it turned out to be access rights. This might be an issue for vm/container environments.

@mattkoch614
Copy link

@aysegeertsma - can you elaborate on the vm/container environments comment? We are experiencing something similar and aren't sure how to fix it.

@jhsbeat
Copy link

jhsbeat commented Apr 21, 2021

  • Laravel version : 6.18.1
  • PHPUnit version : 8.5.2

I've figured out the solution for this problem. It's been solved by setting processIsolation value false in phpunit.xml file.

@JeroenDeDauw
Copy link
Contributor

Adding processIsolation="true" in phpunit.xml fixed the issue for me. I then noticed a .phpunit.result.cache owned by root in my project directory. After removing this file the issue is also gone, even when removing processIsolation.

@hastinbe
Copy link

hastinbe commented May 8, 2021

In my case the issue was caused by a psr-0 autoload definition for Facebook SDK 3.2.2 in a legacy app that's running L8 in parallel with ZF1. Definitions are correct in autoload_classmap. It doesn't occur on our servers nor dev workstation only in our GitHub Action which is getting this error when running pest. The unit tests complete and the error occurs soon as the coverage begins in the GIthub Action. For the fix we removed any access to the legacy psr-0 Facebook sdk from the Laravel side and rewrote using Facebook's modern php-graph-sdk. Our legacy unit tests for ZF1 still work properly using the psr-0 version.

@kushan2
Copy link

kushan2 commented Feb 10, 2022

Try to delete vendor folder and run "composer install" again. should be fixed

@Garym3
Copy link

Garym3 commented Aug 22, 2022

For me, it was simply caused by a mismatch between the name of a PHP file and the name of its class. Fixing it then doing a "composer dump-autoload" fixed the problem.

@BasvanH
Copy link

BasvanH commented Jan 16, 2024

For me it was the .env file missing which gave me these kind of errors.

@carcinocron
Copy link

This is only for issues/bugs with the framework code itself.

I think enough people have encountered this consistently since 2015 to consider this a confirmed framework bug. The only thing that's not clear is if the bug is in laravel or phpunit.

@ahinkle
Copy link
Contributor

ahinkle commented Jun 21, 2024

@carcinocron Only if you can create a reproducible result of the bug where it's clear for the maintainers to investigate. 😉

@alies-dev
Copy link

in my case I used phpunit/phpunit 10.5.27 and changing #[CoversMethod(..)] attribute to #[CoversClass(...)] has solved the issue. I didn't find syntax issues in my CoversMethod usage.

@nbyloff
Copy link

nbyloff commented Sep 6, 2024

This just started happening to me today, but only happens when I run with paratest --parallel command. If I just run php artisan test everything completely successfully.

I will note, when I run with --parallel all the tests complete successfully, but I get this error at the end, not bound to any specific test.

@nbyloff
Copy link

nbyloff commented Sep 11, 2024

To add, in my situation I updated to phpunit 10.5.33 and the issue is now resolved.

@arborrow
Copy link

I have a Laravel 10 project that recently started giving the Uncaught error in Container after parallel tests. I tried setting to 10.5 in the composer.json but am still seeing lower versions in the composer.lock file probably because of some dependencies. I can confirm that without using --parallel the tests run fine. This seems like a minor annoyance but still something that it would be nice to get fixed.

PHP Fatal error: Uncaught Illuminate\Contracts\Container\BindingResolutionException: Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable. in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php:1126
Stack trace:
#0 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(921): Illuminate\Container\Container->notInstantiable()
#1 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(795): Illuminate\Container\Container->build()
#2 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(961): Illuminate\Container\Container->resolve()
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php(731): Illuminate\Foundation\Application->resolve()
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(946): Illuminate\Container\Container->make()
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(288): Illuminate\Foundation\Application->make()
#6 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(207): Illuminate\Foundation\Bootstrap\HandleExceptions->getExceptionHandler()
#7 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(189): Illuminate\Foundation\Bootstrap\HandleExceptions->renderForConsole()
#8 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(231): Illuminate\Foundation\Bootstrap\HandleExceptions->handleException()
#9 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(255): Illuminate\Foundation\Bootstrap\HandleExceptions->handleShutdown()
#10 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->Illuminate\Foundation\Bootstrap{closure}()
#11 {main}
thrown in /var/www/html/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 1126

@arborrow
Copy link

I had an old phpunit.xml file since this project has been around for a while. I went ahead and updated the phpunit.xml to merge in things like processIsolation from https://github.com/laravel/framework/blob/10.x/phpunit.xml.dist, re-ran composer dump-autoload and re-ran the test and am still seeing the issue.

@viirre
Copy link

viirre commented Sep 26, 2024

I got the same error after switching to PHP 8.3. For me, the problem was gone after doing a composer update 🤷

@kelcampus
Copy link

For me, running the composer update resolved the issue on localhost; however, the error continues to occur in the GitLab CI/CD.
Laravel 10 e PHP 8.1 or PHP 8.3

@kelcampus
Copy link

This solved it in my case: #890.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests