从laravel-6.2现有项目中删除包时出现错误。

huangapple go评论54阅读模式
英文:

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,

如果你移除了这个包,请确保:

  1. 删除config/tracker.php文件
  2. config/app.php中删除PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class这行
  3. config/app.php中删除'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade'这行
  4. 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

  1. delete the config/tracker.php file
  2. remove the line PragmaRX\Tracker\Vendor\Laravel\ServiceProvider::class from config/app.php
  3. remove the line 'Tracker' => 'PragmaRX\Tracker\Vendor\Laravel\Facade', from config/app.php
  4. remove the line \PragmaRX\Tracker\Vendor\Laravel\Middlewares\Tracker::class, from app/Http/Kernel.php

huangapple
  • 本文由 发表于 2023年2月16日 15:04:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75468832.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定