laravel / framework

The Laravel Framework.
https://laravel.com
MIT License
32.65k stars 11.04k forks source link

[v11] Spark middleware does not exist #50298

Closed pxpm closed 8 months ago

pxpm commented 8 months ago

Laravel Version

11

PHP Version

8.2

Database Driver & Version

sqlite

Description

local.ERROR: Uncaught ReflectionException: Class "Spark\Http\Middleware\VerifyBillableIsSubscribed" does not exist in Command line code:1
Stack trace:
  thrown {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Uncaught ReflectionException: Class \"Spark\\Http\\Middleware\\VerifyBillableIsSubscribed\" does not exist in Command line code:1
"} 

The middleware is referenced here: https://github.com/laravel/framework/blob/7c680bb58dfb15923209045f99ed5cf46c31f45d/src/Illuminate/Foundation/Configuration/Middleware.php#L739

I am not sure about the fix, or if there is something to fix other than removing that alias. If it were to fix, maybe checking if the class exists before pushing it to router in https://github.com/laravel/framework/blob/7c680bb58dfb15923209045f99ed5cf46c31f45d/src/Illuminate/Foundation/Http/Kernel.php#L456 ? 🤷

Cheers

Steps To Reproduce

just a fresh laravel instalation with: composer create-project laravel/laravel:"dev-master" laravel11

jbrooksuk commented 8 months ago

You need to install Laravel Spark before you may use the middleware.

pxpm commented 8 months ago

@jbrooksuk maybe I am missing something, and sorry if that's the case. But is Spark now a Laravel dependency ?

I just created a new Laravel application using the above mentioned command: composer create-project laravel/laravel:"dev-master" laravel11

Care to re-open or please clarify? This spark alias came with the framework.

Thanks in advance. 🙏

crynobone commented 8 months ago

CleanShot 2024-02-29 at 08 39 21

Unable to replicate the issue with just composer create-project laravel/laravel:"dev-master" laravel11

pxpm commented 8 months ago

CleanShot 2024-02-29 at 08 39 21

Unable to replicate the issue with just composer create-project laravel/laravel:"dev-master" laravel11

Thanks for your time @crynobone

I've updated https://github.com/laravel/framework/pull/50304#issuecomment-1969608513 with my findings.

It's the VSCode PHP Intellisense (static analysis) that wrote those errors on my log file when indexing project files.

image

While on this process, the error pops up in the logs.

To reproduce it, you just need to force your editor to re-index project files.

What annoys me is that I spent quite some time trying to debug this thing, I just saw it on my laravel.log file. No complete stacktrace, no way to reproduce it.

And the solution is to move the alias registration to spark package. I don't get the "convenience" in this case because you need to install spark anyway to use it. So why not have the alias when you install spark and remove it from framework code?

Cheers