lumen-framework: Laravel\Lumen\Application does not implement Illuminate\Contracts\Foundation\Application

  • Lumen Version: 5.8
  • PHP Version: any
  • Database Driver & Version: any

Description:

Laravel\Lumen\Application is meant as a replacement for Illuminate\Foundation\Application, however, it doesn’t implement Illuminate\Contracts\Foundation\Application.

This causes certain DocBlocks to be inaccurate when a library is used with Lumen.

E.g., in https://github.com/illuminate/support/blob/2b426a413e7c9da4b08845b71877b5de450293b5/ServiceProvider.php#L10-L15

Additionally, some libraries use specific type-hinting, and these can fail in Lumen, even though there’s nothing in the code that would prevent Lumen from being used.

E.g., in https://github.com/laravel/cashier/blob/75052f4408ad29d87ac9e0169fa5bab5adb850d3/src/Http/Middleware/VerifyWebhookSignature.php#L34

There’s nothing in Laravel Cashier’s code that prevents it from being compatible with Lumen, however this middleware can’t be used, because it requires that the $app be an implementation of Illuminate\Contracts\Foundation\Application, which Laravel\Lumen\Application is not.

Changes needed:

The following errors occur when Laravel\Lumen\Application implements Illuminate\Contracts\Foundation\Application:

  1. PHP Fatal error: Declaration of Laravel\Lumen\Application::register($provider) must be compatible with Illuminate\Contracts\Foundation\Application::register($provider, $force = false) in /home/drj/repos/work/medology/raven/vendor/laravel/lumen-framework/src/Application.php on line 21

  2. PHP Fatal error: Declaration of Laravel\Lumen\Application::registerDeferredProvider($provider) must be compatible with Illuminate\Contracts\Foundation\Application::registerDeferredProvider($provider, $service = NULL) in /home/drj/repos/work/medology/raven/vendor/laravel/lumen-framework/src/Application.php on line 21

  3. PHP Fatal error: Class Laravel\Lumen\Application contains 5 abstract methods and must therefore be declared abstract or implement the remaining methods (Illuminate\Contracts\Foundation\Application::registerConfiguredProviders, Illuminate\Contracts\Foundation\Application::booting, Illuminate\Contracts\Foundation\Application::booted, ...) in /home/drj/repos/work/medology/raven/vendor/laravel/lumen-framework/src/Application.php on line 21

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 22 (11 by maintainers)

Most upvoted comments

@driesvints The issue isn’t about making Lumen compatible with Cashier. That would be a side effect, but it’s not the issue. The issue is making Lumen more compatible with Laravel.

There are many places in the Laravel codebase in which $app is typed (in DocBlock) as Illuminate\Foundation\Application|Illuminate\Contracts\Foundation\Application, but Laravel\Lumen\Application is neither of those. Having Laravel\Lumen\Application implement that interface would fix this.

@goodevilgenius currently a bit swamped but will try to take a look next thursday

@lloricode I just checked - everything seems to work now!