How to mark code as stable using Composer?

Viewed 19752

I've recently come across the change in composer meaning that the default minimum-stability is stable, and rather than set this to dev I'd like to mark some of my libraries as stable.

I actually use two relevant branches, release and dev branched from master. Every so often something is merged into release and tagged as new version.

How does composer determine the stability of my libraries, is there a naming convention for branches, version nums, a key in composer.json?

Thanks

4 Answers

To answer the question :

  • for VCS, it's dev-master
  • for packagist, it's *@stable

For more about "stabilizing" or "freezing" composer versions

Freeze Make Stable

It's sometimes useful, especially during an audit, to grab latest versions of your requirements, that's why I made a composer package that make stable all your dependencies : Composer Stable Versions (https://github.com/MaximeCulea/Composer-Stable-Versions).

Using this command, your dependencies into composer.json will be automatically be changed from:

"wpackagist-plugin/wordpress-seo":"6.2"

into:

"wpackagist-plugin/wordpress-seo":"*@stable"

Freeze Composer Versions

If afterwards you plan doing the reverse thing to grab latest versions of your composer.lock which you tested your site against, especially useful while making a site live, have a look to an other of my composer command : Composer Freeze Versions (https://github.com/MaximeCulea/Composer-Freeze-Versions).

Using this command, your dependencies into composer.json will be automatically be locked:

"wpackagist-plugin/wordpress-seo":"@stable"

into:

"wpackagist-plugin/wordpress-seo":"6.2"


Hope it helps.

If you don't get your package from a github or a similar repository, but rather for example from the local path, "path" type, you have to have the version explicitly defined in the 'composer.json' file, it won't figure it out from the local git tags. Also, such a package will be installed only if it does not exist on the packagist, github and therefore it might be needed to be temporarily renamed if it exists in the local path composer.json "name" field, to something else.

Related