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 conditional where in Laravel 8

How to use conditional where clause in Laravel 8 eloquent ?

February 7, 2022October 4, 2022

In Laravel sometimes while creating a eloquent or db builder query you wanted to apply the where on basis of some conditions and to achieve it you may use if else condition but laravel 8 itself provides solution to handle such type of situations using when method. Laravel eloquent when…

Read More
Php Laravel 11 CRUD Example Tutorial with Search, Image and Pagination

Laravel 11 CRUD Example Tutorial with Search, Image and Pagination

July 5, 2024July 5, 2024

In this article, we’ll delve into Laravel and explore the implementation of CRUD operations alongside essential features like Search, Image uploading, and Pagination. CRUD, an acronym for Create, Read, Update, and Delete, forms the backbone of database management in web applications across all programming paradigms. This tutorial covers these fundamental…

Read More
Laravel Clear cache in laravel

How to Clear cache in Laravel 8 ?

October 15, 2021October 15, 2021

Cache is used to improve the performance of web application using caching the views templates, queries, CSS, JavaScript etc. Cache improves the performance by serving the cached pages and improves the speed of website but sometime develops face issues like they change something in Laravel application but it does not…

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