Use a Private Package
Using a private Composer package requires two things:
- You must let Composer know where to find the package
- You must provide Composer any authentication info it needs to access the package
You can then require the package like any other!
Here's how it's done.
Define the repository in repositories
Add the package's repository information to the repositories section of the file:
{
"repositories": [
{
"name": "stellarwp/advanced-custom-fields-pro",
"type": "vcs",
"url": "https://github.com/stellarwp/composer-advanced-custom-fields-pro"
}
]
}
Notice that the "name" field does not include the composer- prefix seen in the "url". This is intentional, and it must match the "name" defined in the package repo's composer.json file.
Require the package
From your command line, require the package by "name" from the composer.json:
composer require stellarwp/advanced-custom-fields-pro
Provide auth token if prompted
If Composer prompts you for an authentication token, provide it.
This is necessary for Composer to access the private package.
The token is usually a GitHub Personal Access Token; if you're comfortable making one on your own, you can.
Though you may find it simpler to use the Composer Auth Token item found in the StellarWP → Web Team vault in 1password.
Specify a version
By default, Composer will install the latest version of the package.
If you want to specify a version, you can do so:
composer require stellarwp/advanced-custom-fields-pro:6.2.7
You can also specify the version (or a version range) in the project's composer.json file directly:
{
"require": {
"stellarwp/advanced-custom-fields-pro": "6.2.7"
}
}
You can use any version number that is tagged in the package's GitHub repo. See the Update a Private Package documentation for more info.