Last active
December 28, 2015 06:29
-
-
Save m4rw3r/7457187 to your computer and use it in GitHub Desktop.
Quick attempt at writing some CommonJS-like configuration for a dependency injection container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$module->use('db'); | |
$module->use(new Parameter('table')); | |
$module->import('logger', 'logger', ['name': new Parameter('log_name')]); | |
$module->addParameter('log_name', 'UserLog'); | |
$module->addService('users', new ClassService('UserProvider', | |
[new Reference('db.connection'), new Parameter('table')] | |
)); | |
return [ | |
new Reference('users') | |
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use: | |
- db | |
- $table | |
import: | |
logger: [logger, { name: $log_name }] | |
params: | |
log_name: UserLog | |
services: | |
users: {class: [UserProvider, [db.connection, $table]]} | |
exports: | |
- users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment