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 Use Soft Delete to Temporary (Trash) Delete the Records in Laravel

Use Soft Delete to Temporary (Trash) Delete the Records in Laravel ?

June 17, 2022June 17, 2022

In laravel we use Soft Delete to Temporary (Trash) Delete the Records. Soft delete in laravel is use to hide the record from users by keeping the data in the database. There is many purpose of soft delete like deleting the user for admin but keep all the information in…

Read More
Php Laravel 9 CRUD with Search, Image and Pagination

Laravel 9 CRUD with Search Image upload and Pagination

June 25, 2022November 7, 2023

In this article i will learn laravel 9 CRUD with Search Image upload and Pagination. In this post we will not only cover the CRUD operation but also the validation on form, unique validation, image uploading and view the uploaded image, Flash messages, Search the uploaded data and many more….

Read More
Php How to delete column in laravel migration ?

How to delete column in laravel migration ?

February 17, 2022February 26, 2024

Deleting column to existing table are easy as creating a new table and adding columns to it. To delete column in laravel migration to existing table we can use the same method we used in create migrations . Major difference between creating new table and updating new table is Schema::create…

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

  • 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 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
  • Installing a LAMP Stack on Ubuntu: A Comprehensive Guide
  • Understanding High Vulnerabilities: A Deep Dive into Recent Security Concerns
©2023 Readerstacks | Design and Developed by Readerstacks
Go to mobile version