Use composer dependencies in hologit-projected sites


#1

With emergence-php-core v0.2.0 and lens-composer v0.2.1 it is now possible to make use of composer packages within your site environment

Just add .holo/lenses/composer.toml to apply the lens:

[hololens]
package = "holo/lens-composer"

[hololens.input]
files = "composer-requires/**"

[hololens.output]
merge = "underlay"

Then create composer-requires/<vendor>/<project>.toml files like

[composer-requires]
version = "^1.0"

The lens will generate php-bootstraps/composer-requires.php which emergence-php-core v0.2.0+ will auto-load immediately after emergence’s autoloader is registered and Site class config has been applied. This generated bootstraps file will load composer’s optimized autoloader at php-bootstraps/composer-requires/autoload.php. Since the composer autoloader is registered after emergence’s, PHP classes under php-classes/ will take precedence over any provided by composer. When class loads fall through to composer, any matching ‘php-config/’ scripts will not be applied. This may change in the future.