英文:
Remove package from laravel-6.2 existing project an error occurred
问题
从 Laravel 项目中移除 pragmarx/tracker
包可以使用以下的 Composer 命令:
composer remove pragmarx/tracker
成功移除后,出现了以下错误。即使运行 composer update
也无法解决该错误:
Illuminate\Contracts\Container\BindingResolutionException
Target class [PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker] does not exist.
如何修复这个错误?以及如何完全从 Laravel 中移除未使用的包?
翻译完毕,不提供其他内容。
英文:
Remove pragmarx/tracker
package from laravel project by the following composer command
composer remove pragmarx/tracker
It's remove successfully but the below error shown. Even though composer update
the error not fix.
Illuminate\Contracts\Container\BindingResolutionException
Target class [PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker] does not exist.
How can I fix this error ? and which method to follow to completely remove any unused packages from laravel?
答案1
得分: 1
从repo文档中:
安装
在命令行中执行以下命令以安装
tracker
包:
composer require pragmarx/tracker
将服务提供程序添加到你的app/config/app.php
文件中:PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
在你的
app/config/app.php
文件中添加别名到facade:'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
发布
tracker
配置:Laravel 4
php artisan config:publish pragmarx/tracker
Laravel 5
php artisan vendor:publish --provider="PragmaRX\Tracker\Vendor\Laravel\ServiceProvider"
启用中间件(Laravel 5)
打开新发布的配置文件,位于
app/config/tracker.php
,并启用use_middleware
:
'use_middleware' => true,
将中间件添加到Laravel Kernel(Laravel 5)
打开文件
app/Http/Kernel.php
,并将以下内容添加到你的Web中间件:\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
如果你移除了这个包,请确保:
- 删除
config/tracker.php
文件 - 从
config/app.php
中删除PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class
这行 - 从
config/app.php
中删除'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade'
这行 - 从
app/Http/Kernel.php
中删除\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class
这行
英文:
From the documentation on the repo:
> # Installing
> Require the tracker package by executing the following command in your command line:
>
> composer require pragmarx/tracker
>
> Add the service provider to your app/config/app.php
:
> php
> PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class,
>
> Add the alias to the facade on your app/config/app.php
:
> php
> 'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
>
> ## Publish tracker configuration:
> ### Laravel 4
>
> php artisan config:publish pragmarx/tracker
>
> ### Laravel 5
>
> php artisan vendor:publish --provider="PragmaRX\Tracker\Vendor\Laravel\ServiceProvider"
>
> ## Enable the Middleware (Laravel 5)
> Open the newly published config file found at app/config/tracker.php
and enable use_middleware:
>
> 'use_middleware' => true,
>
> ## Add the Middleware to Laravel Kernel (Laravel 5)
> Open the file app/Http/Kernel.php
and add the following to your web middlewares:
> php
> \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
>
> ...
If you removed the package, make sure to
- delete the
config/tracker.php
file - remove the line
PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class
fromconfig/app.php
- remove the line
'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade',
fromconfig/app.php
- remove the line
\PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class,
fromapp/Http/Kernel.php
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论