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:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Laravel\Passport\Passport' 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?
After following Paul's steps. Remove the Passport Migrations in database migrations table and run command
artisan migrate:refresh
.With Laravel 7, I did it this way:
Step 1. In the file
app/Providers/AuthServiceProvider.php
, remove these two lines:Step 2.
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:Step 4. Find and remove
HasApiTokens
from your models:Remove also the import line going with it:
Step 5. Remove
oauth
keysStep 6. In the file
config/auth.php
, look forguards
:api
:driver
and revert frompassport
totoken
.Step 7. Drop Passport tables and clean migration table
Step 8. And finally, refresh your installation:
You can remove passport by manually deleting this line
"laravel/passport": "^4.0"
in yourcomposer.json
file then runcomposer update
.If you're running Laravel 5.4 or below, make sure to remove this line in your
app.config
fileLaravel\Passport\PassportServiceProvider::class
And all classes that relies on passport must be edited as well. The most common classes are:
User
model, remove theHasApiToken
trait.AuthServiceProvider
, removePassport::routes();
in your boot method.config/auth.php
, change your driver option forapi
authentication