Composer loading from cache
When you remove a package from your composer.json file and clear the vendor/ directory, you might expect the dependency to vanish immediately. Instead, you encounter a frustrating scenario where Composer insists on "Loading from cache" for a package that should no longer exist in your project's requirements. This often happens when switching versions of libraries, such as moving from dflydev/markdown to michelf/php-markdown. Even if the local cache directories appear emptyâspecifically checking AppData\Roaming\Composer on Windows or .cache/composer on Linuxâthe output log still displays the package being loaded from a cached artifact.
The root cause lies in how Composer manages its internal repository cache, distinct from your application's vendor folder. When you run composer update, Composer downloads packages and stores them in two primary locations: the local cache directory (usually hidden inside your project or system cache) and the global cache for metadata. The error message "Loading from cache" indicates that Composer has successfully retrieved the package archive from its internal repository store, bypassing a fresh download from Packagist.
However, the confusion arises when you attempt to uninstall a dependency. If you delete the package from composer.json but do not run a full cleanup, Composer may still have an entry in its local repository cache that references the old version. When you run composer update, it resolves your dependencies based on the current composer.json. If the new requirement (michelf/php-markdown) conflicts with cached metadata or if the resolution strategy picks up an outdated alias, Composer might attempt to load a cached version of the old package to satisfy a transient constraint before realizing the conflict.
To resolve this, you must clear Composer's internal cache, not just the vendor folder. While deleting AppData\Roaming\Composer is often suggested, it is a heavy-handed approach that affects your entire system configuration. The precise command to clear the repository cache for all packages is:
composer clear-cache
This command specifically targets the cache/repo directory within Composer's home folder. After running this, you should also ensure that your local project cache is cleared if you are using a specific version of Composer with caching enabled in your environment variables or configuration files.
There is another layer to consider regarding the "Loading from cache" message itself. It does not necessarily mean the package is incorrect; it simply means Composer found a valid archive for that package name and version constraint in its storage. If you are switching from dflydev/markdown to michelf/php-markdown, note that these are technically different packages with different namespace structures. In older versions of Laravel, the illuminate/view composer service provider might have hardcoded references or aliases that expect specific package names. If you switch libraries without updating the service providers in your config/app.php file, Composer might still try to resolve a dependency chain that expects the old package name, leading to the cache loading behavior even after uninstalling the old one.
In modern Laravel setups (version 5.8 and above), the markdown library is often loaded via the illuminate/view component's internal service provider logic. If you are manually installing these packages for legacy reasons, ensure that your composer.json does not contain any remnants of the old package in the require-dev or require sections, as Composer caches requirements from previous runs if they were part of a locked file (composer.lock).
If you have already deleted the vendor folder and updated composer.json, running composer clear-cache followed by composer update is the standard procedure. This forces Composer to re-evaluate the dependency tree without relying on cached metadata that might reference the old package. If the issue persists, check your composer.lock file; removing it alongside clearing the cache ensures a completely fresh resolution of dependencies.
For projects where you need to switch markdown implementations entirely, remember that simply deleting the vendor folder is insufficient. You must update your service providers and clear Composer's internal cache to prevent "Loading from cache" messages from obscuring potential version mismatches or lingering namespace conflicts.
