nunomaduro/collision

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

Opened this issue · 0 comments

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 …}
      }
    }
  }
}