Composer life hacks

composer which used books as stands for piano

Composer life hacks

Switching between composer 1 & 2:

composer self-update --1   --> switch to composer 1

composer self-update --2   --> switch to composer 2


If you only want to install, upgrade or remove one dependency, you can explicitly list it as an argument:

php composer.phar update monolog/monolog [...]


composer dump-env dev - will generate .env.local.php (which you can change with your needs)


Installing tools globally:

php composer.phar global require friendsofphp/php-cs-fixer
or just 
composer global require friendsofphp/php-cs-fixer


To clear the Composer cache, the standard command is:

composer clear-cache


Rebuild Autoloader: If you added new classes and they aren't being found, use:

composer dump-autoload


This rebuilds the class map and files needed for autoloading.

Optimize Autoloader: To speed up your application (common for production), use:

composer dump-autoload -o


Ignore Cache During Install: To install or update packages without using the local cache at all, add the --no-cache flag:

composer update --no-cache


Manual Cache Removal: If the standard commands fail, you can manually delete the cache directory. You can find your specific cache path by running:

composer config cache-dir

Then, remove that directory manually (e.g., rm -rf <path> on Linux/macOS).

Comments

Popular posts from this blog

Интересное о Формальдегиде

Открываем порт для сервера Minecraft на роутере mikrotik (команда для терминала в WinBox)