Composer is a dependency management tool for PHP. Instead of manually downloading and including libraries in your Concrete project, Composer allows you to define your dependencies and manage them with the command line.
Concrete CMS manages a private Composer repository specifically for packages available in the Concrete CMS Market. Here's how to use it with a Concrete website.
Add the repository Composer configuration to tell Composer to look for packages in the specified Concrete CMS repository.This can be done in two ways:
- Using the Composer CLI:
$ composer config repositories.concretecms composer https://composer.concretecms.org
This command adds the Concrete CMS repository to your project's composer.json
file under the repositories
key.
- Or by manually Editing
composer.json
:
{
"repositories": {
"concretecms": {
"type": "composer",
"url": "https://composer.concretecms.org"
}
}
}
Authorize Composer to access your purchases. Locate your public and private keys either in the Marketplace Site Page for your website or in your website's dashboard (/dashboard/system/basics/marketplace
). Once you have your public and private keys, you need to configure Composer to use them for authentication:
$ composer config --global http-basic.dl.market.concretecms.com <public_key> <private_key>
Replace <public_key>
and <private_key>
with your actual keys. This command sets the authentication credentials globally, meaning they will be used for all projects on your system that interact with this repository.
Download the packages licencsed to your site
$ composer require concretemarket/<your_package>
Replace <your_package>
with the actual package name.
Managing Dependencies Once you have configured your composer.json
file and authenticated Composer, you can manage your project’s dependencies using standard Composer commands. Here are some common ones:
Update Dependencies:
$ composer update
This command updates all the dependencies to the latest version according to the constraints in
composer.json
.Install Dependencies:
$ composer install
This command installs all dependencies listed in the
composer.lock
file, ensuring a consistent environment across different setups.