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

Devops How to install PHP

How to install PHP on Ubuntu?

September 18, 2021October 4, 2022

PHP is widely used langauge in world of web. PHP is an open sourece language and free for everyone. It’s a server side scripting lanaguge which compiles on server and can embedded with html too. Currently, there is three version are available of PHP that are as below PHP 5…

Read More
Php Laravel min in eloquent query

Laravel min in eloquent query with example

January 23, 2022January 23, 2022

In this article we will learn to use aggregate function min in laravel eloquent and query builder. Laravel itself provide inbuilt method to min the columns like in MySQL or SQL based database we can do min of columns using min aggregate function. Min method will give you the most…

Read More
Php How to Upload image with preview in Laravel 9 with example

How to Upload image with preview in Laravel 9 with example ?

May 14, 2022May 14, 2022

Upload image with preview in laravel or for any website can be basic requirement like set up a profile picture to providing the documents. Laravel 9 provides robust functionality to upload and process the image with security. Laravel simply use Request file method to access the uploaded file and then…

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

  • 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

  • Building a Million-Dollar Brand: The Journey of Justin Jackson
  • Mastering Schedule Management with Laravel Zap
  • The Resilience of Nature: How Forests Recover After Fires
  • Understanding Laravel Cookie Consent for GDPR Compliance
  • Understanding High Vulnerabilities: A Critical Overview of the Week of May 12, 2025
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version