2017 © Pedro Peláez
 

library ioc-container

Inversion of Control Container - facilitating Interface Oriented Design

image

bonzer/ioc-container

Inversion of Control Container - facilitating Interface Oriented Design

  • Saturday, April 14, 2018
  • by parasralhan
  • Repository
  • 0 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

IOC Container -- Inversion of Control Container

Facilitating Interface Oriented Design, (*1)

Getting Started

Prerequisites

  • PHP >= 5.4
  • "bonzer/exceptions" : "dev-master"

Installing

It can be installed via composer. Run, (*2)

composer require bonzer/ioc-container

Usage

use Bonzer\IOC_Container\facades\Container as App_Container;

Binding to Container

There are two methods available:
bind or singleton for binding your class with container.
used as:, (*3)

App_Container::bind('My_Class', 'My\Namespace\My_Class');
App_Container::singleton('My_Class', 'My\Namespace\My_Class');

Binding Interfaces:

You can also bind your interfaces with container as:, (*4)

App_Container::bind('My\Namespace\My_Interface', 'My\Namespace\My_Class');

and whenever you use this interfaces in any other class and if that class is bound and/or instantiated via IOC_Container the interface will automatically gets resolved., (*5)

Instantiating

For instantiating, Just call App_Container::make with the bound key:, (*6)

App_Container::make('My_Class');
  • Note: If you have bound with singleton, App_Container::make will return the same instance everytime.

Direct Instantiation:

Direct Instantiation is also possible, without binding. For eg., (*7)

App_Container::make('My\Namespace\My_Class');

for singleton instantiation without binding, use:, (*8)

App_Container::make_singleton('My\Namespace\My_Class');
  • Note: If your class has private constructor, then IOC_Container checks for the availability of any of the two static methods: init or get_instance

Support

If you are having issues, please let me know.
You can contact me at ralhan.paras@gmail.com, (*9)

License

The project is licensed under the MIT license., (*10)

The Versions

14/04 2018

dev-master

9999999-dev

Inversion of Control Container - facilitating Interface Oriented Design

  Sources   Download

MIT

The Requires

 

by Paras Ralhan

14/04 2018

v0.0.1

0.0.1.0

Inversion of Control Container - facilitating Interface Oriented Design

  Sources   Download

MIT

The Requires

 

by Paras Ralhan