How to add or remove package in Laravel application

When you upgrade your Laravel application or doing changes in appliction, then you might want to add new package or remove pacakge from Laravel application. Laravel uses composer package manager to add or remove packages.

Add package in Laravel

You can add new package in Laravel using composer installation command. Suppose you want to install Laravel Passport in your Laravel application.

composer require laravel/passport

This will add all package files into vendor folder. Your application composer.json file is also updated. Composer manages all package through composer.json file.

Remove package from Laravel

In the same way you can remove package from Laravel using composer remove command.

composer remove laravel/passport

This will remove package files from vendor folder and also from composer.json. You can find the pacakges list in composer.json file.

The last step is to remove package class reference from your application e.g., from config/app.php or controller file else it will give class not found error.