如何卸载Laravel Passport

时间:2017-11-30 06:34:18

标签: laravel composer-php

我决定使用JWT并从项目中完全删除Laravel Passport。

我试图从composer remove laravel/passport开始。但是,它没有任何好处:

  [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.

什么是正确和安全的删除程序?

3 个答案:

答案 0 :(得分:18)

您可以手动删除"laravel/passport": "^4.0"文件中的composer.json行,然后运行composer update来删除通行证。

如果您运行的是Laravel 5.4或更低版本,请务必在app.config文件Laravel\Passport\PassportServiceProvider::class

中删除此行

所有依赖护照的课程也必须进行编辑。最常见的课程是:

  1. User模型,删除HasApiToken特征。
  2. AuthServiceProvider,在您的启动方法中删除Passport::routes();
  3. 您的config/auth.php,更改api身份验证
  4. 的驱动程序选项

答案 1 :(得分:9)

使用 Laravel 7 ,我是这样做的:

第1步。在文件app/Providers/AuthServiceProvider.php中,删除以下两行:

use Laravel\Passport\Passport;
Passport::routes();

第2步。

$ composer remove laravel/passport
$ rm -r ./resources/js/components/passport # if any
$ rm -r ./resources/views/vendor/passport # if any

第3步。在文件resources/js/app.js中,删除护照组成部分的注册。如果您在某些地方使用了这些注册组件,也可能会找到并删除它们:

$ grep -rn 'passport-authorized-clients'     resources/js/*
$ grep -rn 'passport-personal-access-tokens' resources/js/*
$ grep -rn 'passport-clients'                resources/js/*

第4步。从模型中查找并删除HasApiTokens

$ grep -rn HasApiTokens * 

还删除与之配套的导入行:

use Laravel\Passport\HasApiTokens;

第5步。删除oauth

$ rm storage/oauth-*.key

步骤6 。在文件config/auth.php中,查找guardsapidriver,然后从passport还原为token

步骤7。删除Passport表并清除迁移表

$ 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

第8步。最后,刷新安装:

$ composer dump-autoload
$ php artisan optimize:clear
$ npm run dev

答案 2 :(得分:2)

按照保罗的步骤进行。删除数据库迁移表中的“ Passport Migrations”并运行命令notEmpty

相关问题