This is a comment on Composer Guide for Beginners, posted by WikiAdmin at 08/06/2026 13:27
View source for Using the dev-master version
To pull the ##dev-master## version of a package via Packagist/Composer, you must explicitly specify the branch name prefixed with ##dev-## and often need to adjust the stability settings.
==== Method 1: Command Line (Recommended) ====
Run the following command in your terminal. This automatically updates your ##composer.json##:
%%(hl bash)
composer require vendor/package:dev-master
%%
If the package is not stable, you may need to add the stability flag:
%%(hl bash)
composer require vendor/package:dev-master@dev
%%
==== Method 2: Manual ##composer.json## Edit ====
Add the package to your ##require## section with the ##dev-master## constraint:
%%(hl json)
{
"require": {
"vendor/package": "dev-master"
}
}
%%
**Crucial Step:** If you receive an error about stability, you must allow dev packages in your ##composer.json## by adding:
%%(hl json)
{
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"vendor/package": "dev-master"
}
}
%%
* **##minimum-stability##**: Allows installation of dev versions.
* **##prefer-stable##**: Ensures stable versions are used for other dependencies where possible.
==== Specific Commit (Optional) ====
If you need to lock ##dev-master## to a specific commit hash to prevent breaking changes:
%%(hl bash)
composer require vendor/package:dev-master#<commit-hash>
%%
Example: ##"vendor/package": "dev-master#a1b2c3d"##
==== Note on Branch Names ====
If the repository uses ##main## instead of ##master## (common in newer projects), replace ##dev-master## with ##dev-main##.