Laravel 10 Remove Composer Package Tutorial

Reading Time: 3 minutes
311 Views

Managing dependencies is an important component of modern web development with Laravel 10, and Composer plays an important role in handling package installations. However, as your project progresses, you may discover that certain Composer packages are no longer required or have become obsolete.

This tutorial will walk you through the process of deleting a Composer package from your Laravel 10 project step by step. We’ll go over the commands and best practises for properly removing the package, as well as how to handle any potential conflicts or issues that may emerge during the process.

Read More: Top 40 Pixwox Alternatives for Viewing and Downloading Instagram Stories

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.

Methods To Remove Composer Package

There are few steps you 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 into app.php file from /config folder.

You need to remove those lines manually from app.php.

Read More: Laravel 10 Custom Validation Rule Tutorial

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.

From “providers“,

'providers' => ServiceProvider::defaultProviders()->merge([
    
    //...
    
    Maatwebsite\Excel\ExcelServiceProvider::class,

])->toArray(),

From “aliases“,

'aliases' => Facade::defaultAliases()->merge([

    // 'Example' => App\Facades\Example::class,

    'Excel' => Maatwebsite\Excel\Facades\Excel::class,
    
])->toArray(),

Step #2: Remove Package Files & Dependencies

When you install any composer package it install 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, you need to clear cached config from application.

$ php artisan config:clear

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

Read More: PeopleTools Att – Benefits and Everything You Need to Know

Online Web Tutor invites you to try Skillshike! Learn CakePHP, Laravel, CodeIgniter, Node Js, MySQL, Authentication, RESTful Web Services, etc into a depth level. Master the Coding Skills to Become an Expert in PHP Web Development. So, Search your favourite course and enroll now.

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.

Sanjay KumarHello friends, I am Sanjay Kumar a Web Developer by profession. Additionally I'm also a Blogger, Youtuber by Passion. I founded Online Web Tutor and Skillshike platforms. By using these platforms I am sharing the valuable knowledge of Programming, Tips and Tricks, Programming Standards and more what I have with you all. Read more