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

PHP Fatal error: Uncaught ReflectionException: Class App\Policies\ModelPolicy does not exist in Command line code:1 #129

Open
Ruko97 opened this issue Oct 16, 2024 · 2 comments

Comments

@Ruko97
Copy link

Ruko97 commented Oct 16, 2024

System: Windows 11
Description: I installed the Laravel Extra Intellisense from the VS Code Extension marketplace. The extension never worked, and the following error message started to occur instead of running properly

PHP Fatal error: Uncaught ReflectionException: Class App\Policies\ModelPolicy does not exist in Command line code:1
Stack trace:
#0 Command line code(1): ReflectionClass->__construct('App\Policies\Mo...')
#1 [internal function]: {closure}('App\Policies\Mo...', 'App\Model')
#2 Command line code(1): array_map(Object(Closure), Array, Array)
#3 {main}
thrown in Command line code on line 1

Because of backward compatibility, I am using PHP 7.4 and Laravel Framework 5.8. Could that be the reason the extension doesn't work?

@papandrk
Copy link

For other projects I have tested this extension with all seems to be working normal.
In one though I get the same error as @Ruko97. I'm not sure why, but inside the file app/Providers/AuthServiceProvider.php there was this:

    /**
     * The policy mappings for the application.
     *
     * @var array
     */
    protected $policies = [
        'App\Model' => 'App\Policies\ModelPolicy',
    ];

I removed the entry and left the $policies array empty and the error stopped popping up! I don't know if I have inadvertently broken something - I hope not! Does anyone know what that entry could be doing there?

@patrick-cullen
Copy link

patrick-cullen commented Dec 17, 2024

@papandrk I'm pretty sure it's a placeholder that was included with the default Laravel installation at some point - if you look for a class called App\Policies\ModelPolicy, you likely won't find it.

For that reason, I wouldn't consider this a bug with this package - it's doing its job!

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

3 participants