framework: 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

  • 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: https://github.com/laravel/framework/issues/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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 23 (5 by maintainers)

Most upvoted comments

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.

Have you tried composer dump-autoload?

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.

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.

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.

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

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.

  • 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.

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