Testing Packages on Composer with Specific Commit Before Creating New Tag

Composer, which is a modern developer tool for dependency management for PHP. It is used to declare the dependencies your project depends on it and it manages them very well for you. It is incredibly flexible to manage the dependencies in various stage of your project.

Let's suppose you're releasing a new package, but before announcing a new major stable version, you want to test it thoroughly in the development branch.

Now, to use the specific git commit before publishing a new tag, composer offers a way to include the commit hash value directly via the command line or via the require block in the composer.json file.

composer require vendor/package:dev-master#0fcf728


    "require": {
        "vendor/package": "dev-master#0fcf728"

The composer command above will check out your package version to that specific commit, so you can test the code properly before finally releasing a stable version.

Also, sometime you may want to install a specific released version of the package.

composer require vendor/package:version

// Example 
composer require sudiptpa/paypal-ipn:1.0.x-dev

Also Read: Speed up your Composer Install or Update Process

Thanks for reading the article up to the end, if you have any feedback feel free to leave your comment below.

If it is worth reading, let other people know about it by sharing this post.

Happy Coding!