php - Automatically discover composer packages -
i'm wondering best way (if there way) application auto-discover [relevant] php "packages" installed composer.
my utilize case specific scenario:
i have php app includes "framework" (for lack of improve word). framework brings basic functionality (routing, admin etc).
i'm building in more advanced functionality, say, blog module. module exclusively self contained in it's own directory (but has dependencies on framework).
i'd blog module self contained composer package, can selectively require bundle in app's root composer.json file.
now, need framework know it's there can, example, set routing correctly , load admin functionality module requires.
what i've thought far:
i'm relatively experienced in php, "proper" oop , autoloading little bit beyond knowledge @ moment, please forgive if there inbuilt functions this. don't know terms google!
i have thought maybe read installed.json file composer puts @ vendor/composer/installed.php
i'm not sure how set packages (e.g. blog
) announce are. i'd future proof i'm not looking known module names (or regexing vendor or bundle names), rather looking packages "hey framework, know you! can utilize me!"
maybe can somehow instruct composer (through package's composer.json file) stick in arbitrary key/value pair in installed.json?
any suggestions welcome, or directions sort of googling should doing.
oh welcome world of managing dependencies on framework.
i have experience auraphp, dealt similar issue. can read blog post composer-assisted two-stage configuration .
so ended-up adding https://github.com/auraphp/aura.web/blob/a3870d1a16ecd3ab6c4807165ac5196384da62cd/composer.json#l26-l36 these lines in packages need understand load framework.
you can see how bundle can autoloaded configurations.
in composer.json
https://github.com/harikt/aura.asset_bundle/blob/6ea787979390e69bf6ecb1e33ce00ed90f306e2f/composer.json#l21-l27
and config/common.php
( https://github.com/harikt/aura.asset_bundle/blob/223126cedb460e486c4f0b242719c96c14be5385/config/common.php ) , note have other development modes also. detailed check https://github.com/auraphp/aura.web_project or https://github.com/auraphp/aura.framework_project
hope helps bit code , work on own solution.
php json composer-php
No comments:
Post a Comment