Composer extra/component : howto?

I’d like to use a LeagueCSV inside snippets.

I guess need do create a component in order to load LeagueCSV classes to use it inside a snippet.

Is there a tutorial explaining how build an extra/component with a composer installation command (e…g. :composer require league/csv:^9.0 )

In most cases, you run that locally before building a transport package that has the vendor directory inside of it.

To run a composer install from a composer.json (and/or .lock) during the installation, you can use a composer resolver like we’ve done here. (Note that requires placing a composer.phar in the core files). Note that this installation approach works well across the vast majority of servers, and doesn’t even require PHP have the ability to run a CLI command.

The additional benefit of that approach is cleanup: package installations normally merge directories, while composer replaces versions entirely. So it keeps a cleaner vendor directory across updates.

In the future it would be great if we could somehow hook into the core and have a single vendor directory with all packages required by installed extras, but as of yet that’s unresolved.