Erweiterungen / Composer packages connector

Provide basic integration with packages installed to project with Composer.

#1. PackageConnector

Plugin for CMF Cotonti. Provide smooth integration with packages installed to project with Composer (Dependency Manager for PHP).

#2. Description

First of all Package Connector allow to use autoloader for all Composer installed packages. That is practical way to use installed PHP package without a headache with manual adding require /include directive with proper library paths.

Beside this it has interface to installed package info. Using it you can get info about package version, requirements (and other info provided by Composer package).

#3. Features

  • Support and use Composer generated autoloader
  • Getting complete info about installed package (version, requirements, etc.)

#4. Requirements

Current version 0.2.1 works with Cotonti Siena v0.9.18. (can work in older versions but not tested)

For use it needs at least composer.json located in base folder of working project (base folder with Cotonti install).

For getting info about installed packages there should be composer.lock file (normally generated by Composer itself after package installation):

composer install

or adding certain package to the project:

composer require "vendor/package"


Plugin works out right after had been installed and not require any addition settings.

#4.2. How extension works

Inspite of PackageConnector class can be easily integrated right into the core it distributed now as a extension Plugin «package_connector».

Plugin utilizes main routines (see file package_connector.input.php) that serve class usage, like class initialization and data caching.

Plugin defines in a global scope variable $cot_packages — instance of PackageConnector class:

$cot_packages = new PackageConnector();

Class instance with necessary data are cached:

$cache && $cache->db->store('cot_packages', $cot_packages, 'system');

To eliminate needless initialization (with loading and parsing files data) class had stateChanged()method to check state of composer files. If state had changed you can reinitialize (setup) Connector once more:

if ($cot_packages->stateChanged()) $cot_packages->setup();

More detailed info for Class can be found on library repo «Package Connector»

#5. Install

  • Unpack, copy files to root folder of your site.
  • Install via Admin → Extensions menu (Administration panel → Extensions)

Pay attention: file PackageConnector.php with library classes for PackageConnector should be located in system class folder system\classes.

#6. Licence

Distributed under BSD license.

#7. Author

Andrey Matsovkin

#8. References

1. Graber  31. August 2016, 21:22

Отличный плагин, большое спасибо!

Но почему не добавить в плагин базовый composer.json (да хоть из Валенсии), или это связанно с изменением пути с lib/ на lib/components в system/resources.php?


2. Macik  10. September 2016, 21:39

Замечание резонное — добавил.

Insgesamt: 2, auf Seite: 2

Nur registrierte Benutzer können Kommentare schreiben