Laravel 使用 composer 删除包

Laravel deleting package with composer

我试图从我的 laravel 安装中删除 barryvdh/laravel-debugbar,但似乎我做错了什么。

到目前为止我做了什么:

我遇到了一个错误:

[RuntimeException]
Error Output: PHP Fatal error:
Class 'Barryvdh\Debugbar\ServiceProvider' not found in 
{mypath}\vendor\laravel\framework\src\Illuminate\Foundation\ProviderRepository.php on line 146

我尝试了自动转储、清晰编译,但 none 有效。

我错过了什么?


22/02/2016 编辑:我也尝试删除所有 vendor 文件夹,然后通过 composer install 重新安装它,但是当命令 php artisan clear-compiled又是运行。

当您安装 Debugbar 时,通过 composer 安装包后,您需要将 class 添加到 config/app.php 中的 providers 数组。所以你需要从那里删除这一行:

Barryvdh\Debugbar\ServiceProvider::class

如果您还注册了门面,那么您需要从同一文件的 aliases 数组中删除以下内容:

'Debugbar' => Barryvdh\Debugbar\Facade::class

如果您还 运行 php artisan vendor:publish(这是包自述文件 Installation Section 中描述的最后一步),那么您也可以删除 config/debugbar.php 文件, 尽管保留该配置文件不会导致任何问题。

好的,看来我玩过 artisan 命令,配置文件被缓存了(via php artisan config:cache)。

我删除了它(在 bootstrap/cache/config.php 中)并且一切正常,但我也可以使用命令 php artisan config:clear 将其删除。

你必须:

首先。删除 config/app.php

中对 Debugbar 的引用

其次。作曲家删除 barryvdh/laravel-debugbar

按照这个顺序。如果不这样做,Laravel 会感到困惑 ;)

Marc Brillault 的回答是正确的。我正在对该答案添加更多说明:

我从捕获文件中手动删除了调试栏 class。出现在 (bootstrap/cache/config.php).

如何手动删除的步骤class。

1.) Open this two files 
   `bootstrap/cache/config.php`
   `config/app.php`

2.) Find this two line and remove It.        
    Barryvdh\Debugbar\ServiceProvider::class,
   'Debugbar' => Barryvdh\Debugbar\Facade::class,

3.) run command `php artisan config:clear`

执行完此步骤后检查命令 php artisan list 是否运行良好。

您需要做的最好方法是手动删除所有作曲家文件中的所有文件。