Just a word for people who love using CommonJS Module pattern but have to deal with PHP projects at work, like me :-)
It has the following CommonJS features:
- Modules run in a "Closure sandbox"
- a $require method, available in or outside Modules
- in the Modules sandbox we have access to the following variables (and only to them):
- the $require function
- a $exports array, for exposing stuff
- a $module array, with $module['id'] and $module['uri'] properties according to the CommonJS spec. One can also set a direct export with $module['exports'].
Furthermore, I have added 2 features inspired by RequireJS : a "defined-by-Closure" functionallity with a "$define" function, and Modules "plugins" with the syntax $require('[plugin name]![resource path']').
I also added a PHP version of Node's "Folder as Module".