Skip to content

Composer

Get the code (alternative method - Composer)

Composer is a dependency management tool which can add, upgrade and remove software packages for your site.

If composer is properly installed and setup to install WordPress via composer, then these example commands will add latest CiviCRM version to WordPress:

cd /var/www/wp.example.org
composer config extra.enable-patching true
composer require civicrm/civicrm-{core,packages,wordpress,asset-plugin}
composer require civicrm/cli-tools

More detail: Enable patching

A handful of packages used by CiviCRM require extra patch-files.

This is possible with the popular cweagans/composer-patches plugin. However, you must opt-in to enable it.

CiviCRM Asset Plugin

CiviCRM Asset Plugin is used to copy css/js and other static assets from the vendor directory to the plugin directory.

Configure the paths that CiviCRM Asset Plugin copies files to in the "extra" section of the composer.json. You must set the path to the location of the 'civicrm' directory inside the CiviCRM Wordpress plugin directory.

For example, for the Bedrock Wordpress composer template, set as:

"extra": {
    "civicrm-asset": {
        "path": "web/app/plugins/civicrm/civicrm",
        "url": "/app/plugins/civicrm/civicrm"
        "assets:packages": {
            "+include": ["kcfinder/**.php"]
        }
    }
}

After adding this and requiring the civicrm packages, execute the command:

composer civicrm:publish

civicrm.settings.php userFrameworkResourceURL

Currently one modification to one setting is necessary in the civicrm.settings.php after installation with a composer based codebase.

For the 'userFrameworkResourceURL' setting add /core to the end of the path that CiviCRM generates in the civicrm.settings.php.

The example below is for a Bedrock composer template directory structure.

// Just add "/core" to what civicrm generates here.
$civicrm_setting['domain']['userFrameworkResourceURL'] = 'https://mysite.org/app/plugins/civicrm/civicrm/core';