安装完 jetstream 包后,通过 composer remove laravel/jetstream命令移除包只是删除了包文件,但是项目中仍然后很多改包发布的其他文件,下面介绍一下如何完整的移除 jetstream 包发布的内容。

首先编辑以下文件,删除其中包含的内容,前面是文件路径,后面是要删除的内容。

app/Http/Kernel.php - LaravelJetstreamHttpMiddlewareAuthenticateSession::class
config/app.php - AppProvidersFortifyServiceProvider::class
config/app.php - AppProvidersJetstreamServiceProvider::class
routes/web.php - 所有包含 auth:sanctum 的路由

然后删除下面的所有文件。

app/Providers/FortifyServiceProvider.php
app/Providers/JetstreamServiceProvider.php
app/View/Components/AppLayout.php
app/View/Components/GuestLayout.php
app/Actions/Fortify/
app/Actions/Jetstream/

config/fortify.php
config/jetstream.php
config/sanctum.php
config/fortify.php

如果用到了 Livewire 或者 inertiajs 等前端脚手架,可能在 resource 目录中还存在着大量的组件,根据实际情况也可以选择是否要删除。