Details taylorotwell


User Guide


php artisan bundle:install linject

Bundle configuration:

'linject' => array(
    'autoloads' => array(
        'map' => array(
            'Linject\\Container' => '(:bundle)/container.php',

The Basics

Linject is a powerful, reflection based IoC container that quickly resolves abstract types (Interfaces) to concrete implementations. It is useful for building flexile, testable, and complex applications. Linject can also resolve any concrete type without any configuration.

For an overview of Inversion of Control (IoC) and dependency injection, check out Martin Fowler's article on the topic.

Binding Types

Binding an interface to an implementation:

Linject\Container::bind('IRepository', 'Repository');

Sometimes you may want the container to create one instance of the object, but return the same instance on each subsequent request for that type.

Registering a binding to be managed as a singleton:

Linject\Container::singleton('IRepository', 'Repository');

Resolving Types

Resolving an implementation of an interface:

$repository = Linject\Container::resolve('IRepository');

Note: The container throws an instance of Linject\Exception on unresolvable types.


You can install this bundle by running the following CLI command:

php artisan bundle:install linject

Alternatively you can download it directly from GitHub:


  • Watchers:
  • Forks:
  • Ratings: 1 likes
  • Installs: 3241