How to clear PHP composer cache or delete its folder?

While working with PHP Composer, are you facing slow performance then to improve it and the efficiency of managing dependencies try to clear the cache of Composer for your Project.

Well, those are not familiar but reading this article then it is a dependency manager for applications written in PHP. For example, to install Laraval, you can use the Composer to install libraries and dependency packages required by it using a single command.

However, occasional malfunctions can occur due to Composer cache storage issues. So, clearing the composer cache could help developers or users to resolve many issues.

Clearing the PHP Composer cache

In this article, we will learn the command that we can use for clearing the composer cache on Linux, Windows, and Mac OS. Along with a syntax to remove its cache folder, if required.

Open Command Terminal:

Open your command prompt or terminal and navigate to the root directory of your project. After that, simply run  the built command of Composer to clear the cache:

composer clear-cache

For example, in the screenshot, we are inside our Laravel directory and to remove the cache we use the above command.

Clear the PHP Composer Cache

Delete the entire Composer cache folder

Alternatively, if any of you want to completely delete the composer cache directory then for that here is the command to follow:

rm -rf ~/.composer/cache

After clearing the cache execute the composer update command to update the packages to their latest version or install new packages without any issues.

composer update

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.