问题
What is the right way to remove a package from Laravel 4? So long I\'ve tried:
- Remove declaration from
composer.json
(in \"require\" section) - Remove any Class Aliases from
app.php
- Remove any references to the package from my code :-)
- Run
composer update
- Run
composer dump-autoload
Not working! Am I missing something?
Some packages publish their configuration via \"artisan config:publish ...\". Is there a way to \"unpublish\" them?
回答1:
Running the following command will remove the package from vendor (or wherever you install packages), composer.json and composer.lock. Change vendor/package appropriately.
composer remove vendor/package
Obviously you'll need to remove references to that package within your app.
I'm currently running the following version of composer:
Composer version 1.0-dev (7b13507dd4d3b93578af7d83fbf8be0ca686f4b5) 2014-12-11 21:52:29
回答2:
Got it working... The steps to remove a package from Laravel are:
- Remove declaration from composer.json (in "require" section)
- Remove Service Provider from "app/config/app.php" (reference in "providers" array)
- Remove any Class Aliases from "app/config/app.php"
- Remove any references to the package from your code :-)
- Run "composer update vendor/package-name". This will remove the package folder from "vendor" folder and will rebuild composer autoloading map.
- Manually delete the published files (read comment by zwacky)
It will remove the package folder from "Vendor" folder
回答3:
Running the following command
composer remove Vendor/Package Name
That's all. No need composer update. Vendor/Package Name is just directory as installed before
回答4:
Normally composer remove
used like this is enough:
$ composer remove vendor/package
but if composer package is removed and config cache is not cleaned you cannot clean it, when you try like so
php artisan config:clear
you can get an error In ProviderRepository.php line 208:
Class 'Laracasts\Flash\FlashServiceProvider' not found
this is a dead end, unless you go deleting files
$rm bootstrap/cache/config.php
And this is Laravel 5.6 I'm talking about, not some kind of very old stuff.
It happens usually on automated deployment, when you copy files of a new release on top of old cache. Even if you cleared cache before copying. You end up with old cache and a new composer.json.
回答5:
you can remove any package just by typing follwing command in terminal, and just remove the providers and alias you provided at the time of installing the package, if any and update the composer,
composer remove vendor/your_package_name
composer update
回答6:
You can do any one of the below two methods:
Running the below command (most recommended way to remove your package without updating your other packages)
$ composer remove vendor/package
Go to your composer.json file and then run command like below it will remove your package (but it will also update your other packages)
$ composer update
回答7:
If you are still getting the error after you have done with all above steps, go to your projects bootstrap->cache->config.php
remove the provider & aliases entries from the cached array manually.
回答8:
Before removing a package from composer.json declaration, please remove cache
php artisan cache:clear
php artisan config:clear
If you forget to remove cache and you get class not found error then please reinstall the package and clear cache and remove again.
回答9:
**
use "composer remove vendor/package"
** This is Example: Install / Add Pakage
composer require firebear/importexportfree
Uninsall / Remove
composer remove firebear/importexportfree
Finaly after removing:
php -f bin/magento setup:upgrade
php bin/magento setup:static-content:deploy –f
php bin/magento indexer:reindex
php -f bin/magento cache:clean
回答10:
Simpliest and Easiest way
Syntax:
composer remove <package>
Example:
composer remove laravel/tinker
回答11:
In case the given answers still don't help you remove that, try this:
Manually delete the line in
require
fromcomposer.json
Run
composer update
回答12:
You can remove any package by typing following command in terminal, and just remove the providers and alias you provided at the time of installing the package and update the composer
composer remove <package_name>
composer update
回答13:
To remove a package using composer command
composer remove <package>
To install a package using composer command
composer require <package>
To install all packages which are mentioned in composer.json
composer install
To update packages
composer update
I used these for Laravel project
来源:https://stackoverflow.com/questions/23126562/how-to-remove-a-package-from-laravel-using-composer