Closed thekid closed 4 years ago
The following usage patterns exist:
// 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:
$inject= new Injector(Bindings::using() ->typed(Repository::class, InDatabase::class) ->named('templates', new Path($webroot, 'src/main/handlebars')) ->instance(DriverManager::getConnection($dsn)) ->singleton(TemplateEngine::class) );
The following usage patterns exist:
Here's the DSL form of the above: