Home / Snippets / How to Remove Package Dependency From Laravel using PHP Composer?
How to Remove Package Dependency From Laravel using PHP Composer? cover

How to Remove Package Dependency From Laravel using PHP Composer?

583

3 years ago

0 comments

In this short snippet, you will learn how to remove package dependency from Laravel using the PHP composer package manager. There are 2 ways, the first method is the automatic way and the second method is to use the manual way to remove the package manager.

Method 1: Automatically Using Composer Command


If you are using composer to install your package, you will need to run the "composer require" command and passing the package name to install.
composer remove <package>
For this example code below, it will install the "spatie/laravel-sitemap" package.
composer require spatie/laravel-sitemap
Now to remove the package you can run the "composer remove" command which will automatically remove the package from the dependency list.
composer remove spatie/laravel-permission

Method 2: Manually Remove


If you want to manually remove the package then you can open the "composer.json" and manually deleting the package from the dependency list.
  1. Open composer.json and remove dependency
  2. Delete the package folder from the "vendor" folder.
  3. Run "composer update" from the terminal to update composer.lock
By now you will have the dependency removed from your Laravel project.

Optional Command To Run


You may also run "composer dump-autoload" once you have done the remove command and this will autoload all of the package dependencies.
notion avatar

Alaz

Week-end developer currently experimenting with web, mobile, and all things programming.

Topics:

Frontend

Resource

Average

Average

Support Us

If you like our tutorial, support us by being our Patreon or buy us some coffee ☕️

Welcome to PostSrc V3

PostSrc Dark Logo

You have to login to favorite this