Skip to content
Readerstacks logo Readerstacks
  • Home
  • Softwares
  • Angular
  • Php
  • Laravel
  • Flutter
Readerstacks logo
Readerstacks
How to remove installed package from laravel project using composer

How to remove installed package from laravel project using composer ?

Aman Jain, March 5, 2022March 5, 2022

Composer is used to manage the dependencies of project and sometimes we wanted to remove installed packages from laravel. As we can add the package using simple command composer install package_name in the same way we can remove the package using

composer remove package_name

In this article i will show you to remove the the package completely from the project. To remove the package we can use above command if we have not used this package classes in anywhere in our project but what if we have used the classes of this project in our project like config\app.php and also the service provider. In some cases we manually add service provider and alias so we also need to remove them manually.

If you just want to remove the package from vendor then you can use above command composer remove package_name or if your package is not auto discovery featured off then you can use below steps to remove the installed package completely.

How to remove installed package completely manually in laravel ?

In some cases above command not work so we can follow the below steps to remove the package completely from project. we will take an example of https://github.com/tylernathanreed/laravel-relation-joins package so lets start remove installed package in laravel step by step

Step 1 : Remove declaration from composer.json

Firstly we need to open compose.json file and remove the "reedware/laravel-relation-joins": "^2.4" from the file

 "require": {
        "php": "^7.3|^8.0",
        "doctrine/dbal": "^3.3",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "harimayco/laravel-menu": "^1.4",
        "laravel/framework": "^8.54",
        "laravel/sanctum": "^2.11",
        "laravel/tinker": "^2.5",
        "readerstacks/querymigration": "^1.1",
        "reedware/laravel-relation-joins": "^2.4"
    },

Updated file:

 "require": {
        "php": "^7.3|^8.0",
        "doctrine/dbal": "^3.3",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "harimayco/laravel-menu": "^1.4",
        "laravel/framework": "^8.54",
        "laravel/sanctum": "^2.11",
        "laravel/tinker": "^2.5",
        "readerstacks/querymigration": "^1.1",
    },

Step 2 : Remove service provider of package

While we add our package in laravel we also add service provider so we also need to remove it from config\app.php file if the package not support auto discovert feature. After open the file go to providers array and remove the entry as below

 'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        ....
        Reedware\LaravelRelationJoins\LaravelRelationJoinServiceProvider::class,
        Readerstacks\QueryMigration\QueryMigrationServiceProvider::class,
  ],

Updated File :

 'providers' => [

        /*
         * Laravel Framework Service Providers...
         */
        ....
        Readerstacks\QueryMigration\QueryMigrationServiceProvider::class,
  ],

Step 3 : Remove alias of package

In some packages we also add our package in laravel alias list so we also need to remove it from config\app.php file. After open the file go to aliases array and remove the entry as below

 'aliases' => [

        /*
         * Laravel Framework Class Aliases...
         */
        ....
         'QrCode' => SimpleSoftwareIO\QrCode\Facades\QrCode::class,
         'Date' => App\Facades\DateHelperFacade::class,
  ],

If you don’t find any alias then you can skip this step.

Step 4 : Remove references of package from project code

May be we have used the some code and classes of this package in our code so we need to remove it . For example i have used the the code of this package in my controller

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use LaravelRelation;  //Need to remove


class ArticleController extends Controller
{

    public function index(Request $request)
    {
        User::query()->joinRelation('posts'); // i need to remove this
    }
}

Updated File :

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ArticleController extends Controller
{

    public function index(Request $request)
    {
         
    }
}

Step 5: Run composer command

Now run composer update or delete command

composer update vendor/package-name
//or 
composer update
composer dump-autoload
Note : You also need to remove assets and views file of package if you have published while installing the package

Step 6: Clear Cache

Also clear the cache of routes, config and view so that we will have not any cache in app


php artisan cache:clear
php artisan config:clear
php artisan route:clear 
php artisan view:clear

Related

Php Laravel Laravel 9 composerlaravelremove package

Post navigation

Previous post
Next post

Related Posts

Php How to use limit query in Laravel Eloquent

How to use limit query in Laravel eloquent query with example

February 5, 2022October 4, 2022

Limit clause is used to restrict the number of rows return in executed query. It’s quite useful when working with large data set since querying the large data creates performance issues so to overcome with the large dataset issue we use limit clause in a query. Laravel Limit clause accepts…

Read More
Php How to Use Multiple Database Connection in Laravel

How to Use Multiple Database Connection in Laravel ?

August 16, 2022March 16, 2024

Laravel has ability to make use database connection and can be used any of connection at runtime. In this article i will show you to use multiple database connection in laravel from different servers and then use these connection in our application during the run time according to use of…

Read More
Uncategorized Laravel ajax form with example

Submit form using jQuery in Laravel

November 18, 2021November 18, 2021

jQuery is most popular library to handle the client side events like form submit, click, change etc. In this article we will learn to submit the form using jQuery Ajax method. Ajax is mostly used when we do not want to reload the page and real time interaction. In this…

Read More

Aman Jain
Aman Jain

With years of hands-on experience in the realm of web and mobile development, they have honed their skills in various technologies, including Laravel, PHP CodeIgniter, mobile app development, web app development, Flutter, React, JavaScript, Angular, Devops and so much more. Their proficiency extends to building robust REST APIs, AWS Code scaling, and optimization, ensuring that your applications run seamlessly on the cloud.

Categories

  • Angular
  • CSS
  • Dart
  • Devops
  • Flutter
  • HTML
  • Javascript
  • jQuery
  • Laravel
  • Laravel 10
  • Laravel 11
  • Laravel 9
  • Mysql
  • Php
  • Softwares
  • Ubuntu
  • Uncategorized

Archives

  • August 2025
  • July 2025
  • June 2025
  • May 2025
  • April 2025
  • October 2024
  • July 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • July 2023
  • March 2023
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Recent Posts

  • The Transformative Power of Education in the Digital Age
  • Understanding High Vulnerabilities: A Closer Look at the Week of July 14, 2025
  • Exploring Fresh Resources for Web Designers and Developers
  • The Intersection of Security and Technology: Understanding Vulnerabilities
  • Mapping Together: The Vibrant Spirit of OpenStreetMap Japan
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version