Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How can I remove a package from Laravel using PHP Composer?

What is the correct way to remove a package from Laravel using PHP Composer?

So far I've tried:

Remove declaration from file composer.json (in the "require" section)
Remove any class aliases from file app.php
Remove any references to the package from my code :-)
Run composer update
Run composer dump-autoload

None of these options is working! What am I missing?
by

2 Answers

Bharatgxwzm
Run the following command:
composer remove Vendor/Package Name


That's all. There isn't any need to update Composer. The Vendor/Package Name is just a directory as installed before.
sandhya6gczb
Normally composer remove used like this is enough:

composer remove vendor/package
But if a Composer package is removed and the "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 the cache before copying. You end up with an old cache and a new composer.json file.

Login / Signup to Answer the Question.