Closed thekid closed 4 years ago
The following usage patterns exist:
$inject= new Injector(new ConfiguredBindings(new Properties('app.ini'))); // Bind interface to implementation, the "default" usage $inject->bind(Repository::class, InDatabase::class); // Named $inject->bind(Path::class, new Path($webroot, 'src/main/handlebars'), 'templates'); // Instances $inject->bind(DBConnection::class, $conn); // Singleton $inject->bind(TemplateEngine::class, $inject->get(TemplateEngine::class));
Here's the DSL form of the above:
$injector= new Injector(Bindings::using() ->properties(new Properties('app.ini')) ->typed(Repository::class, InDatabase::class) ->named('templates', new Path($webroot, 'src/main/handlebars')) ->instance(DriverManager::getConnection($dsn)) ->singleton(TemplateEngine::class) );
See #22
The following usage patterns exist:
Here's the DSL form of the above:
See #22