How to use Composer with Marketplace extensions

Aug 22, 2024

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:

  1. 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.

  1. 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.

Recent Tutorials
Bi-directional Express associations
Dec 18, 2024
By myq.

Set up associations between Express entries in both directions

Display Express Data Across Multiple Sites
Dec 17, 2024
By myq.

A guide to configuring Express entities and the Express Entry List block to ensure proper data display across multiple sites.

Customize locale icons
Oct 29, 2024
By myq.

How to customize locale (language region) flags

Concrete CMS Caching Guide
Oct 16, 2024

An overview of types of caching in Concrete and considerations when using them.

Redirect all requests to HTTPS
Oct 9, 2024
By myq.

How to follow best practices for a secure web

Upgrade Concrete versions 9.3.1 and 9.3.2
Sep 10, 2024
By myq.

How to get past a bug in versions 9.3.1 and 9.3.2 that prevents upgrading the Concrete core through the Dashboard

Improvements?

Let us know by posting here.