Using Composer with Joomla

From Joomla! Documentation

Revision as of 17:47, 26 October 2022 by Cmb (talk | contribs) (Changed some URL markup. Other markup changes.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Other languages:
English • ‎Nederlands • ‎español • ‎français • ‎português
≥ 3.4

Composer is a widely-used tool for dependency management when utilizing third-party libraries. The Joomla! Project introduced Composer into Joomla 3.4 to easily manage library dependencies in both the core and extensions. Composer is now a stable product widely used in the PHP community to update libraries that are registered and listed at Packagist, which serves as a directory of available download packages including the Joomla! Framework packages. In this document you'll find out how the CMS is using Composer and how to update the libraries it loads. Learn more about Composer at the their website.

Where are the Composer Files Located?[edit]

The Composer files are located in

JPATH_ROOT . '/libraries/vendor';

Can You Edit Files Loaded with Composer?[edit]

No You should never edit any files imported with Composer (including the Joomla! Framework packages). These are third-party libraries and, similar to all core files, should be enhanced by submitting pull requests on the respective project or extended and overridden in the same manner as any other core functionality.

Where are the Joomla! Framework Files Located?[edit]

Each are hosted in a separate repository. You can find them by going to the Joomla Framework website and searching for the appropriate package.

How Can I Update Libraries from Composer?[edit]

Get Composer from their Download page and run

composer update --no-dev

This will update all Composer files to the latest versions allowed in the composer.json file. If you feel that the versions located in the composer.json file are insufficient, update them by submitting a Pull Request. However, remember that Joomla promises backwards compatibility in the CMS through a major series. This includes the Joomla! Framework packages!

Are Composer Files Autoloading?[edit]

All classes loaded via Composer are automatically autoloaded by the CMS.

Can You Install Any Extra Libraries Via Composer?[edit]

Not at the moment in Joomla! 3.4. In the longer term it is the CMS's aim that you can download extra packages. To emphasize this, we will not yet be releasing the composer.json file within the main Joomla! download.