How to Remove Composer Package in Laravel 9 Tutorial

Share this Article
Reading Time: 4 minutes
1,314 Views

Inside this article we will see how to remove a installed composer package from laravel 9 application. When we work with application according to use we generally install several composer packages. If not needed then we uninstall or remove composer package from laravel 9 setup.

When composer package installs it updates composer.json file in laravel application. Also when we remove any package updates that file. composer.json is the package manager file for any composer based php application.

This tutorial will be very easy to understand and also easy to remove compose package from your application. We will see all steps to remove composer package in laravel 9 in a very detailed way.

Learn More –

Let’s get started.

Laravel Installation

Open terminal and run this command to create a laravel project.

$ composer create-project laravel/laravel myblog

It will create a project folder with name myblog inside your local system.

To start the development server of laravel –

$ php artisan serve

URL: http://127.0.0.1:8000

Assuming laravel already installed inside your system.

Steps To Remove Composer Package

There are few steps we need to follow to remove a composer package in a proper way from laravel application.

  • Remove Package Providers and Aliases (if any)
  • Remove Package Files
  • Clear Cached Config

Step #1 – Remove Provider and Alias

If you have added any provider line in providers and alias line in aliases array of /config/app.php file.

You need to remove those manually from app.php.

You can take an example like this –

Here, we have installed a excel composer package and added these lines inside app.php.

To remove these lines, find and simply delete that.

'providers' => [

    ...
    
     Maatwebsite\Excel\ExcelServiceProvider::class,
],

'aliases' => [
 
    ...

    'Excel' => Maatwebsite\Excel\Facades\Excel::class,
]

Step #2 – Remove Package Files & Dependencies

When you install any composer package it installs several files. So to remove those files in a proper way from application, here is the syntax of composer command to remove any package.

Syntax

$ composer remove <packageName>

Example

$ composer remove maatwebsite/excel

Step #3 – Clear Config

Next, we need to clear cached config from application.

$ php artisan config:clear

Successfully, you can remove a composer package from laravel application in a proper way.

We hope this article helped you to learn How to Remove Composer Package in Laravel 9 Tutorial in a very detailed way.

Buy Me a Coffee

Online Web Tutor invites you to try Skillshare free for 1 month! Learn CakePHP 4, Laravel APIs Development, CodeIgniter 4, Node Js, etc into a depth level. Master the Coding Skills to Become an Expert in Web Development. So, Search your favourite course and enroll now. Click here to join.

If you liked this article, then please subscribe to our YouTube Channel for PHP & it’s framework, WordPress, Node Js video tutorials. You can also find us on Twitter and Facebook.

Was this post helpful?

Learn Web Development Courses Risk Free @ $5 only.
Web Development Courses @ $5