Reputation: 1
I don't know what I have done with my Laravel 5.3 Project but I have this error in Laravel log:
local.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 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalErrorException(code: 1): 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 at Command line code:1) [stacktrace] #0 {main} "}
my app.php
'providers' => [
/* * Laravel Framework Service Providers... */ Illuminate\Auth\AuthServiceProvider::class, Illuminate\Broadcasting\BroadcastServiceProvider::class, Illuminate\Bus\BusServiceProvider::class, Illuminate\Cache\CacheServiceProvider::class, Illuminate\Foundation\Providers\ConsoleSupportServiceProvider::class, Illuminate\Cookie\CookieServiceProvider::class, Illuminate\Database\DatabaseServiceProvider::class, Illuminate\Encryption\EncryptionServiceProvider::class, Illuminate\Filesystem\FilesystemServiceProvider::class, Illuminate\Foundation\Providers\FoundationServiceProvider::class, Illuminate\Hashing\HashServiceProvider::class, Illuminate\Mail\MailServiceProvider::class, Illuminate\Notifications\NotificationServiceProvider::class, Illuminate\Pagination\PaginationServiceProvider::class, Illuminate\Pipeline\PipelineServiceProvider::class, Illuminate\Queue\QueueServiceProvider::class, Illuminate\Redis\RedisServiceProvider::class, Illuminate\Auth\Passwords\PasswordResetServiceProvider::class, Illuminate\Session\SessionServiceProvider::class, Illuminate\Translation\TranslationServiceProvider::class, Illuminate\Validation\ValidationServiceProvider::class, Illuminate\View\ViewServiceProvider::class, /* * Package Service Providers... */ Laravel\Passport\PassportServiceProvider::class, /* * Application Service Providers... */ App\Providers\AppServiceProvider::class, App\Providers\AuthServiceProvider::class, App\Providers\BroadcastServiceProvider::class, App\Providers\EventServiceProvider::class, App\Providers\RouteServiceProvider::class, ], /* |-------------------------------------------------------------------------- | Class Aliases |-------------------------------------------------------------------------- | | This array of class aliases will be registered when this application | is started. However, feel free to register as many as you wish as | the aliases are "lazy" loaded so they don't hinder performance. | */ 'aliases' => [ 'App' => Illuminate\Support\Facades\App::class, 'Artisan' => Illuminate\Support\Facades\Artisan::class, 'Auth' => Illuminate\Support\Facades\Auth::class, 'Blade' => Illuminate\Support\Facades\Blade::class, 'Broadcast' => Illuminate\Support\Facades\Broadcast::class, 'Bus' => Illuminate\Support\Facades\Bus::class, 'Cache' => Illuminate\Support\Facades\Cache::class, 'Config' => Illuminate\Support\Facades\Config::class, 'Cookie' => Illuminate\Support\Facades\Cookie::class, 'Crypt' => Illuminate\Support\Facades\Crypt::class, 'DB' => Illuminate\Support\Facades\DB::class, 'Eloquent' => Illuminate\Database\Eloquent\Model::class, 'Event' => Illuminate\Support\Facades\Event::class, 'File' => Illuminate\Support\Facades\File::class, 'Gate' => Illuminate\Support\Facades\Gate::class, 'Hash' => Illuminate\Support\Facades\Hash::class, 'Lang' => Illuminate\Support\Facades\Lang::class, 'Log' => Illuminate\Support\Facades\Log::class, 'Mail' => Illuminate\Support\Facades\Mail::class, 'Notification' => Illuminate\Support\Facades\Notification::class, 'Password' => Illuminate\Support\Facades\Password::class, 'Queue' => Illuminate\Support\Facades\Queue::class, 'Redirect' => Illuminate\Support\Facades\Redirect::class, 'Redis' => Illuminate\Support\Facades\Redis::class, 'Request' => Illuminate\Support\Facades\Request::class, 'Response' => Illuminate\Support\Facades\Response::class, 'Route' => Illuminate\Support\Facades\Route::class, 'Schema' => Illuminate\Support\Facades\Schema::class, 'Session' => Illuminate\Support\Facades\Session::class, 'Storage' => Illuminate\Support\Facades\Storage::class, 'URL' => Illuminate\Support\Facades\URL::class, 'Validator' => Illuminate\Support\Facades\Validator::class, 'View' => Illuminate\Support\Facades\View::class, ],
OS : Windows 10 Localhost : Laragon PHP Version : 5.7
That's my package.json
{ "name": "laravel/laravel", "description": "The Laravel Framework.", "keywords": ["framework", "laravel"], "license": "MIT", "type": "project", "require": { "php": ">=7.1.3", "barryvdh/laravel-cors": "^0.11.2", "beyondcode/laravel-websockets": "1.3", "dacastro4/laravel-gmail": "^5.1", "doctrine/dbal": "^2.8", "fideloper/proxy": "~4.0", "guzzlehttp/guzzle": "^6.3", "html2text/html2text": "^4.3", "jenssegers/mongodb": "", "laravel/framework": "^5.7", "laravel/passport": "^7.0", "laravel/socialite": "4.4.1", "laravel/tinker": "~1.0", "lcobucci/jwt": "^3.4", "league/csv": "^9.1", "league/oauth2-client": "^2.7", "microsoft/microsoft-graph": "^1.110", "moloquent/moloquent": "", "mongodb/laravel-mongodb": "", "php-amqplib/php-amqplib": "", "phpseclib/phpseclib": "2", "pusher/pusher-php-server": "~3.0", "soundasleep/html2text": "^2.1", "symfony/process": "^4.3", "webklex/laravel-imap": "^4.1" }, "require-dev": { "barryvdh/laravel-ide-helper": "^2.7", "filp/whoops": "~2.0", "fzaninotto/faker": "~1.4", "mockery/mockery": "~1.0", "phpunit/phpunit": "~7.0", "symfony/thanks": "^1.0" }, "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\": "app/" } }, "autoload-dev": { "psr-4": { "Tests\": "tests/" } }, "extra": { "laravel": { "dont-discover": [ ] } }, "scripts": { "post-root-package-install": [ "@php -r "file_exists('.env') || copy('.env.example', '.env');"" ], "post-create-project-cmd": [ "@php artisan key:generate" ], "post-autoload-dump": [ "Illuminate\Foundation\ComposerScripts::postAutoloadDump", "@php artisan package:discover" ], "post-update-cmd": [ "Illuminate\Foundation\ComposerScripts::postUpdate", "php artisan ide-helper:generate", "php artisan ide-helper:meta" ] }, "config": { "preferred-install": "dist", "sort-packages": true, "optimize-autoloader": true } }
Upvotes: 0
Views: 1402
Reputation: 157
It's because you're passing a string when registering policies rather than the actual class.
Here's an example from Laravel Docs
use App\Policies\PostPolicy;
use Illuminate\Support\Facades\Gate;
/**
* Register any authentication / authorization services.
*/
public function boot(): void
{
Gate::define('update-post', [PostPolicy::class, 'update']);
}
What you seem to be doing is just passing a string such as
'App\Policies\Policy'
That's what I seem to be getting anyway from the context provide in the comment you made.
Please provide more context in your questions if you want better answers. At the moment it's very hard for anyone to try and help you because you've made it difficult to do so.
Upvotes: 0