How to Remove a Package from Laravel using Composer?
Remove a package from Laravel using composer it’s so simple and easy you can do with the step by step process which I have given in this article How to Remove a Package from Laravel using Composer?.
Step 1 : Remove declaration from composer.json.
#composer.json "require": { ... "barryvdh/laravel-dompdf": "^0.8.6", //remove ... },
Step 2 : Remove Service Provider and Class Aliases from config/app.php (providers and aliases array).
#config/app.php 'providers' => [ ... Barryvdh\DomPDF\ServiceProvider::class,//remove ... ], 'aliases' => [ ... 'PDF' => Barryvdh\DomPDF\Facade::class,//remove ... ],
Step 3 : Remove any references to the package from your code (Like Conroller,Model,Views etc file).
#remove pdf function. public function pdf(Request $request) { $model = Model::all(); $pdf = PDF::loadView('jobsheet.pdf', compact('model')); $pdf->save(storage_path('pdf/').'devnote.pdf'); return $pdf->download('devnote.pdf'); }
Step 4 : Run below command. This will remove the package folder from vendor folder and will rebuild composer autoloading map.
Syntax : composer remove vendor/package name Example : composer remove barryvdh/laravel-dompdf
Also Read : How to get all installed packages with version in composer?
Now check package remove form list.
composer show - i
Step 5: Manually delete the published files.
It will remove the package folder from vendor folder.
Then composer update below command to :
composer global update
And
composer dump-autoload
composer dump-autoload it just regenerates the list of all classes that need to be included in the project (autoload_classmap.php). you execute composer dump-autoload -o for a faster load of your webpages.
Now you can remove a package from Laravel using composer