How to clear Composer cache on Mac

It’s safe to clear Composer cache on a Mac: it holds packages and package information Composer downloaded, and your projects and their vendor folders stay. Composer trims the cache by itself, so it rarely grows huge, and the vendor folders of old projects often take more space. This guide covers both.

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned
  1. Open MacWashing and choose System Junk in the sidebar.
  2. Click Start Scan.
  3. Look through what it found and click Clean. Anything debatable stays unchecked.

Free trial · macOS 14 or later

Where Composer keeps its cache

Composer saves every package it downloads, so the next install of the same version comes from disk. On a Mac the cache is usually in ~/Library/Caches/composer, and in older setups in ~/.composer/cache. This command prints the folder on your Mac:

composer config --global cache-dir
Terminal: the Composer cache folder

From time to time Composer cleans the cache by itself: by default it removes files unused for six months and keeps the package files under 300 MiB. So the cache is rarely huge.

How to clear Composer cache with composer clear-cache

This command deletes everything in Composer’s cache folders. The packages installed in your projects stay:

composer clear-cache
Terminal: composer clear-cache clears each of Composer’s cache folders

The same command has two short names, composer clearcache and composer cc. To run only Composer’s own cleanup of old files instead of clearing everything, add --gc:

composer clear-cache --gc

Delete vendor folders of old projects

Each PHP project keeps its packages in its own vendor folder, and together these folders often take more space than the cache. In a project you don’t work on now, move vendor to the Trash. Keep composer.json and composer.lock: when you come back, this command in the project folder installs the same versions again:

composer install

Delete vendor only where it sits next to composer.json: in other kinds of projects a folder with that name may hold the project’s own code. If a project keeps vendor in Git, deleting it shows up as changes.

Finder, a PHP project: the context menu of vendor next to composer.json with «Move to Trash»

With MacWashing, it’s one click

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

System Junk in MacWashing clears the Composer cache under App Caches, along with the caches of your other apps. Project Dependencies lists the vendor folders of PHP projects you haven’t changed for 90 days, unchecked, so you decide which to delete.

Free trial · macOS 14 or later

Questions and answers

Will MacWashing delete my own files when it cleans?

No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.

What about apps that are open?

If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.

Is it free?

Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.

Is it safe to clear Composer cache?

Yes. It holds copies of packages Composer can download again. Your projects keep working: they use the packages in their own vendor folders.

What is the difference between clear-cache, clearcache and cc?

None. They are three names of the same command.

Why doesn’t clearing the cache free much space?

Composer trims its cache by itself, so it often takes only a few hundred megabytes. More space usually sits in the vendor folders of your projects.