English 中文(简体)
如何解除安放Laravel护照
原标题:How to uninstall Laravel Passport
I ve decided to use JWT and completely remove Laravel Passport from the project. I was trying to start with composer remove laravel/passport. However, it does no good: [SymfonyComponentDebugExceptionFatalThrowableError] Class LaravelPassportPassport not found Script @php artisan package:discover handling the post-autoload-dump event returned with error code 1 Removal failed, reverting ./composer.json to its original content. What could be the right and safe removing procedure?
最佳回答
You can remove passport by manually deleting this line "laravel/passport": "^4.0" in your composer.json file then run composer update. If you re running Laravel 5.4 or below, make sure to remove this line in your app.config file LaravelPassportPassportServiceProvider::class And all classes that relies on passport must be edited as well. The most common classes are: User model, remove the HasApiToken trait. AuthServiceProvider, remove Passport::routes(); in your boot method. Your config/auth.php, change your driver option for api authentication
问题回答
With Laravel 7, I did it this way: Step 1. In the file app/Providers/AuthServiceProvider.php, remove these two lines: use LaravelPassportPassport; Passport::routes(); Step 2. $ composer remove laravel/passport $ rm -r ./resources/js/components/passport # if any $ rm -r ./resources/views/vendor/passport # if any Step 3. In the file resources/js/app.js, remove passport components registration. You may also find and remove these registered components if you used it somewhere: $ grep -rn passport-authorized-clients resources/js/* $ grep -rn passport-personal-access-tokens resources/js/* $ grep -rn passport-clients resources/js/* Step 4. Find and remove HasApiTokens from your models: $ grep -rn HasApiTokens * Remove also the import line going with it: use LaravelPassportHasApiTokens; Step 5. Remove oauth keys $ rm storage/oauth-*.key Step 6. In the file config/auth.php, look for guards:api:driver and revert from passport to token. Step 7. Drop Passport tables and clean migration table $ php artisan tinker >>> Schema::drop( oauth_access_tokens ); >>> Schema::drop( oauth_auth_codes ); >>> Schema::drop( oauth_clients ); >>> Schema::drop( oauth_personal_access_clients ); >>> Schema::drop( oauth_refresh_tokens ); >>> DB::table( migrations )->where( migration , like , %_oauth_access_tokens_table )->delete(); >>> DB::table( migrations )->where( migration , like , %_oauth_auth_codes_table )->delete(); >>> DB::table( migrations )->where( migration , like , %_oauth_clients_table )->delete(); >>> DB::table( migrations )->where( migration , like , %_oauth_personal_access_clients_table )->delete(); >>> DB::table( migrations )->where( migration , like , %_oauth_refresh_tokens_table )->delete(); >>> exit Step 8. And finally, refresh your installation: $ composer dump-autoload $ php artisan optimize:clear $ npm run dev
After following Paul s steps. Remove the Passport Migrations in database migrations table and run command artisan migrate:refresh.
Couldn t comment under devondahon s reply. After following all steps from devondahon s answer, make sure to delete migration files from database/migrations. any migration that contains create_oauth Then run php artisan migrate:fresh --seed (if you want to refresh database. Not applicable for live site. --seed is for seeding sample data)




相关问题
Table of calificacions in php and laravel

I created a table in order to show the name of the students, name of the subjects and the grade of the subject of the student I have the next code: this is the index part <form action="{{ ...

How to fix CORS for Capacitor/Quasar App in a Laravel API

I have an App built on top of Quasar and Capacitor, with an API built on top of Laravel. Everything works well on the dev environment until I build and install the app on my phone, then I keep getting ...

Laravel +Vuejs CORS issue

I am facing a dilemma wit the CORS issue. I have application that is configured as follow: API: https://abc.mydomain.com (laravel) front end: https://subdomain.mydomain.com(VueJS) Both applications ...

Laravel wrong redirecting to login page after login

In a multi tenancy with subdomain enviroment (http://zapburger.dex.local) when user fills login form with valid data and make login, laravel redirect to dashboard route (as expected) and then redirect ...

热门标签