Download the PHP package liftkit/dependency-injection without Composer

On this page you can find all versions of the php package liftkit/dependency-injection. 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 dependency-injection

Dependency Injection

A simple but featured dependency injection library, with automatic class-resolution.

Create a new container

Rules

A rule is an anonymous function that defines how to create an object.

Singleton rules

A rule will execute each time getObject is called by default. In order to force it to execute only once, we use setSingletonRule. Each call to getObject for the rule will return the same object.

Rules with parameters

Some rules can have parameters passed to them. The first argument to the setRule callback is the container istelf. Each subsequent argument is supplied by an optional array of parameters supplied to getObject.

Rules that reference other rules

Overriding rules

Rules can be overridden by redefining them. This is useful for modular code.

Storing an instance

You can also store an object you've already created an bind it to a rule.

Automatic resolution

The container can also bind a rule to a class. An instance of a class can be created automatially by looking at the typehints of each constructor argument. In the case below, and instance of B is automatically created before creating an instance of A. The newly-created instance of B is then injected into the constructor of A.

Automatic resolution with rules

In some cases, you may need to tell the injector to create an instance following a different rule when it encounters the typehint of a certain class instead. In the example below, a rule is created for the construction of B. When the container realizes it needs an instance of B when creating an A, it will follow that rule to create B first. In this case, A's constructor was injected with an instance of B created by the rule 'GiveMeANewB' to create $a.

Automatic resolution with parameters

Sometimes, there are additional parameters that need to be passed to the constructor of a new instance that is being automatically constructed. Below the variables $param1 and $param2 will be injectied into C's constructor, while B will be created by the rule 'GiveMeANewB' above. Any additional parameters must fall at the end of the constructor's list of parameters.

Binding classes to aliases

Sometimes, you may want the container to resolve to a subclass when it encounters a particular typehint. In the example below, a new instance of D will be injected into A, instead of an instance of B.


All versions of dependency-injection with dependencies

PHP Build Version
Package Version
Requires psr/container Version ^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 liftkit/dependency-injection contains the following files

Loading the files please wait ....