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

Laravel 11: "Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable." when withExceptions is disabled #311

Open
claudiodekker opened this issue Sep 25, 2024 · 0 comments

Comments

@claudiodekker
Copy link

claudiodekker commented Sep 25, 2024

Since Laravel 11, the bootstrap/app.php file has the following lines included by default:

    ->withExceptions(function (Exceptions $exceptions) {
        //
    })->create();

Theoretically, if you don't want an exception handler, you should be able to remove these lines (except for the ->create() chain, of course), and the (console) app should still run just fine. However, Collision currently blindly assumes this binding is always there: https://github.com/nunomaduro/collision/blob/v8.x/src/Adapters/Laravel/CollisionServiceProvider.php#L61

As a result, Collision can crash the application (quietly, since we literally just removed the default error-handler), leading to (amongst others) empty php artisan output.

While the goal of this library is obviously to have error reporting, I'd argue that even without error reporting enabled in your app, Collision shouldn't be the one causing the crashes. Instead, it should probably skip service provider registration (since the package is installed, but error reporting is currently disabled)


Illuminate\Contracts\Container\BindingResolutionException^ {#106
  #message: "Target [Illuminate\Contracts\Debug\ExceptionHandler] is not instantiable."
  #code: 0
  #file: "./vendor/laravel/framework/src/Illuminate/Container/Container.php"
  #line: 1195
  trace: {
    ./vendor/laravel/framework/src/Illuminate/Container/Container.php:1195 { …}
    ./vendor/laravel/framework/src/Illuminate/Container/Container.php:947 { …}
    ./vendor/laravel/framework/src/Illuminate/Container/Container.php:815 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1047 { …}
    ./vendor/laravel/framework/src/Illuminate/Container/Container.php:751 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1029 { …}
    ./vendor/nunomaduro/collision/src/Adapters/Laravel/CollisionServiceProvider.php:61 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:869 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php:75 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:844 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php:37 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:316 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:474 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php:195 { …}
    ./vendor/laravel/framework/src/Illuminate/Foundation/Application.php:1204 { …}
    ./artisan:14 {
      › $status = (require_once __DIR__.'/bootstrap/app.php')
      ›     ->handleCommand(new ArgvInput);
      ›
      arguments: {
        $input: Symfony\Component\Console\Input\ArgvInput {#42 …}
      }
    }
  }
}
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

1 participant