Posts Learn Components Snippets Categories Tags Tools About
/

How to Remove Package Dependency From Laravel using PHP Composer?

Learn how to remove package dependency from Laravel using PHP composer package manager the easy way

Created on Sep 27, 2021

555 views

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.

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

new

PostSrc Code Components

Collection of Tailwind CSS components for everyone to use. Browse all of the components that are right for your project.

View Components

Sponsors 👑

+ Add Yours
)