Composer auto self-update

Composer doesn’t have a feature to automatically run self-update to my knowledge. Also, running self-update by itself doesn’t seem like the right way. Maybe you don’t have permission? Then try using sudo, like: sudo composer self-update. It is just a simple command, and you should only need to do it once about every 30 days. … Read more

How do I use a Git submodule with a Composer loaded library?

Unfortunately* Composer doesn’t support Git submodules, as the main aim of Composer is to provide a similar inter-project dependency functionality and it would be pointless to try to replicate submodules in Composer. I have the same problem that you are trying to solve, of developing a library while simultaneously developing the application that uses that … Read more

Sort packages without adding/updating dependencies

To quote from the Composer manual “Config” section: sort-packages Defaults to false. If true, the require command keeps packages sorted by name in composer.json when adding a new package. So if you run composer config sort-packages true you command Composer to add the following to your composer.json file: { “config”: { “sort-packages”: true } } … Read more

Composer Content-Length Mismatch

First, run: composer config –list –global //this will get the composer home path. [home] /root/.composer //it’s my composer home path. And then, edit the config.json, make it like this: { “config”: { “github-protocols”: [ “https” ] }, “repositories”: { “”: { “type”: “composer”, “url”: “” } } } It will make the packagist connection force … Read more

Is “content-hash” a mandatory part of composer.lock?

Purpose of the content hash As you can see in Composer\Package\Locker::getContentHash(), the content hash takes into account the following fields of composer.json: $relevantKeys = array( ‘name’, ‘version’, ‘require’, ‘require-dev’, ‘conflict’, ‘replace’, ‘provide’, ‘minimum-stability’, ‘prefer-stable’, ‘repositories’, ‘extra’, ); The only reason for the content hash to change is a change of one of the values of … Read more

Difference between PSR-4 and classmap autoloading?

PSR-4 standard requires of you a strict filesystem structure based on namespaces. Say you have an app in src directory with App namespace, then all sub-namespaces will mirror subdirectories and class names will be the same as file names without the .php extension. { “autoload”: { “psr-4”: { “App\\”: “src/” } } } src/ Foo/ … Read more

How to use a specific tag/version with composer and a private git repository?

How to require a specific Git tag? Change the version requirement to dev-master, followed by a hash # and the Git tag name, e.g. v0.5.0, like so: “require”: { “vendor/package”: “dev-master#v0.5.0” } How to require a specific Git commit? Change the version requirement to dev-master, followed by a hash # and the Git commit reference, … Read more