Share this:

Hello dev, Today we are going to learn How can I remove a package from Laravel using PHP Composer?. Laravel, the popular PHP framework, provides developers with a convenient way to manage dependencies through Composer. Composer simplifies package installation and management by handling version constraints, autoloading, and dependency resolution. However, there may come a time when you need to remove a package from your Laravel project.

In this blog post, we’ll explore the steps required to remove a package using PHP Composer.

Step 1: Locate the Package

Before removing a package, you need to identify its name. Typically, package names follow a naming convention that includes the vendor name and the package name, separated by a forward slash.

For example, if you want to remove a package named “acme/blog-package,” take note of this information as it will be necessary for the removal process.

Step 2: Open the Composer.json File

Next, you’ll need to locate and open the composer.json file in the root directory of your Laravel project.

This file serves as the configuration file for Composer and contains essential information about your project, including its dependencies.

Step 3: Remove the Package

Inside the composer.json file, you’ll find a section called "require" or "require-dev" that lists all the packages required by your project.

Locate the entry for the package you want to remove and delete it from the appropriate section. Make sure to remove the entire line related to the package, including its name and version constraint.

For example, if you want to remove the “acme/blog-package” package, you might find the following line in your composer.json file:

"require": {
    "acme/blog-package": "^1.0",

Delete the entire line containing "acme/blog-package": "^1.0" from the "require" section.

Also Read : Laravel 10 Bootstrap Add Product to Shopping Cart Tutorial

Step 4: Update Composer

After removing the package entry from the composer.json file, you need to run a Composer command to update your project’s dependencies.

Open your terminal or command prompt, navigate to your project’s root directory, and execute the following command:

composer update

This command instructs Composer to analyze the composer.json file, resolve dependencies, and update the project accordingly. It will remove the specified package and any associated dependencies that are no longer needed.

Also Read : How to Delete Multiple Data using Checkbox in Laravel 10

Step 5: Verify and Clean Up

Once the Composer update command completes, you should review the output to ensure that the package and its dependencies were successfully removed.

Check for any error messages or warnings that might indicate issues during the removal process.

Additionally, it’s a good practice to remove any leftover files or directories associated with the package manually.

Although Composer takes care of removing the package’s dependencies, it might not remove any additional assets or configuration files provided by the package.

Also Read : How to Set, Get, and Delete Cookies in Laravel 10


Using Composer, removing a package from your Laravel project is a straightforward process. By following these steps, you can remove unwanted packages, declutter your project, and ensure that only the necessary dependencies are present.

Remember to always update your project’s documentation and any code that may reference the removed package to maintain consistency and avoid any unexpected behavior. Happy coding!

Share this:

Categorized in: