myComponents : how to include dependencies?

Hello,
I’d like to include a dependency extra by using MyComponents.

I saw this page “Package Dependencies”
https://docs.modx.com/revolution/2.x/developing-in-modx/advanced-development/package-management/package-dependencies

I know I can easily add a subpackage but

  1. I don’t know if it’s the right way regarding licence because the subpackage is not one of mine.

  2. Can I add this code :

requires’ => array(
‘formit’ => ‘>=2.2.0’,
)

directly in MyComponents config file (e.g. example.config.php) ?

It won’t work to put that in the MC config file, but you should be able to put in in your build.transport.php file like this:

$attr = array(
    'license' => file_get_contents($sources['docs'] . 'license.txt'),
    'readme' => file_get_contents($sources['docs'] . 'readme.txt'),
    'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'),
    'requires' => array(
        'formit' => '>=2.2.0',
    ),
);

MyComponent will never modify an existing build.transport.php file.

You can include other peoples’ work as long as you meet the criteria in their license statement. Most MODX extras have a GPL license, so it’s fine to include them as long as you distribute their license along with them (which will happen automatically with MyComponent).

Thank you very much Bob ! It works perfectly !

I’m glad I could help. Thanks for reporting back. :slight_smile: