Download the PHP package hgraca/micro-di without Composer

On this page you can find all versions of the php package hgraca/micro-di. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package micro-di

Hgraca\MicroDI

Author Latest Version Total Downloads

Build Status Coverage Status Quality Score

A small dependency injection library that uses reflection and a service locator container, to instantiate and recursively resolve, instantiate and inject dependencies.

Installation

To install the library, run the command below and you will get the latest version:

Usage

Factories

The factories used in Builder::buildFromFactory need to extend Hgraca\MicroDI\FactoryInterface.

The method Builder::buildFromFactory instantiates the factory and calls the create method on it. The arguments given to Builder::buildFromFactory will be used both when instantiating the factory and when calling the create method:

Dependency resolution process

The builder will resolve and instantiate dependencies. The dependencies, both when instantiating and when calling a method with Builder::call, will fe filled in the following priority:

  1. By matching the dependencies names with the name of the provided arguments
  2. If its a class/interface, it will try to instantiate it, which in turn:
    1. tries to fetch it from the container, by searching for the class/interface fqcn as one of the containers keys
      1. If the key (class/interface fqcn) is found:
        • If its an instance, it will be used (singleton)
        • If its a closure, it will be used to instantiate the required class (singleton)
        • If its a factory, it will be used to build the required class through the method Builder::buildFromFactory, and build a new instance every time (making it not a singleton)
      2. If the key (class/interface fqcn) is not found:
        1. If its a class it will be instantiated (recursively resolving and injecting its dependencies) and it will be cached in the container
        2. If its an interface, an error will be thrown
  3. If its not a class/interface it will try to find the dependencies in the container, by their name.
  4. If it fails to find all mandatory dependencies, it will throw an error while instantiating the class.

Todo


All versions of micro-di with dependencies

PHP Build Version
Package Version
Requires php Version >=7.0
hgraca/cache Version ^1.0.0
hgraca/helper Version ^1.1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package hgraca/micro-di contains the following files

Loading the files please wait ....