Search code examples
phpgitcomposer-phppackagist

how do I version my composer package


I have just published my first Laravel plugin with composer and Packagist.

Now, How should I manage version???

When I push my Git, I should be able to make a

composer update

and get the changes, but I couldn't do it.

I saw a lot of plugin that has no "version" field in the composer.json, but have versions in packagist...

I tried to tag my branch with v0.7.1 but it didn't resolve automatically...

How should I get my pushes with composer update?

EDIT:

I changed it, but composer update still doesn't do anything :( enter image description here


Solution

    1. Tag with bare version numbers
      • eg: 0.7.1 not v0.7.1
      • Might not be 100% required, but it's how I do it and it works.
    2. Tags are not pushed by default.

      By default, the git push command doesn’t transfer tags to remote servers. You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches – you can run git push origin [tagname].

      ...

      If you have a lot of tags that you want to push up at once, you can also use the --tags option to the git push command. This will transfer all of your tags to the remote server that are not already there.

      • Alternatively, you can set the tags via your git host's GUI.
    3. Using git tags has the added benefit of automagic zip dist generation at git hosts like Github and Gitlab, which are picked up by packagist and rolled into your package info.

    4. Update the package at packagist, wait a lil bit for the repo itself to update, and run composer clearcache in the meantime.