'Modular design for composer package
I'm working on a framework-like application, for which I would like people to be able to develop modules.
Modules add additional functionality to the core application by providing information to the core about their capabilities. Examples include modules for allowing access to MySql, or the file system or emails.
While modules can provide as much or as little extra functionality as they like, there is a Module class that is used to wrap the functionality provided, and each module should provide at least one of these classes to be included into the application.
Are there any guides or good practices on methods of module registration in PHP in the composer ecosystem. It would be additionally useful if the modules could provide aliases, and describe any configuration they require.
Clarification Edit
I have a core application, we'll call it example-app
Anyone using example-app should be able to introduce new functionality easily using the modular framework of the app.
So, let's say we have two modules example-module-1 and example-module-2. The app needs to know that these modules exist when it is run from the command line.
Everything should be managed from composer, so you will require the core application, and any modules that you wish to use with it. For example
"require" : {
"php": ">=5.5.0",
"example/example-app" : "^1.0",
"example/example-module-1": "^1.0",
"example/example-module-2": "^1.0"
},
What I would like to know is, is there a methodology for the modules to inform the core app at the time of installtion of their existence.
I already have a Module interface that imported modules can sit inside of, I just need a way to make the core app aware of where these classes are defined amongst all the other composer installed dependencies (e.g. I don't want to create a huge class list and step through each one doing instanceof).
The only thing I can think to do at the moment is to provide an additional companion app (something like bin/example-app-config) that each module calls as part of it's composer scripts. It could use cli parameters to tell the core app what the module class is called as well as any other requirements it has. However this doesn't sit right with me as it seems like it wouldn't be OS independent.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
