Download the PHP package thamtech/yii2-di without Composer

On this page you can find all versions of the php package thamtech/yii2-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 yii2-di

Yii2 Dependency Injection Enhancements

Yii2-di provides some enhancements to Yii2's dependency injection framework.

Installation

The preferred way to install this extension is through composer.

or add

to the require section of your composer.json file.

Usage

Instance

The Instance::ensureAny() method can be used in place of Instance::ensure() if you would like to ensure that an object is one of any number of specified types.

For example,

Instance Provider

The InstanceProvider class adds support for using providers in your dependency injection implementation. This can be used for several purposes, such as lazy or optional retrieval of an instance or as a marker for certain instance types.

Lazy/Optional Retrieval

You may want to inject an object into a class, but the class may not need the object instantiated yet (or ever). In this case, you can inject a provider instead and let your class decide if and when to get() the object instance.

For example,

Provider as Marker Class

Java developers might be used to using annotations on abstractly typed parameters to specify particular versions of the instance.

For example,

To accomplish something similar with Yii's dependency injection, you can create marker class implementations of InstanceProvider and define your marked components in the dependency injection container.

For example,

In the example above, the FooCacheProvider and BarCacheProvider subclasses of InstanceProvider are used as marker classes that indicate which type of cache component to provide via dependency injection.

The default implementation of InstanceProvider will look for instances defined in the container with a name corresponding to the subclass provider's class name. The Provider suffix is dropped, and a :::provided suffix is appended.

So the example\package\FooCacheProvider's get() method is going to use the container to look for an instance defined as example\package\FooCache:::provided.

You can override this behavior by overriding one or more of $class, $params, and $config properties when you implement your InstanceProvider subclass.

For example,

Type Safety

As seen above, you can configure the provider to return objects of any type via overriding class properties or via container definitions. You may want to enforce a certain level of type safety.

For example, if FooCacheProvider should only return certain cache types, you could specify it as follows:

This will ensure that your application will throw an exception if someone accidentally configures it to return something else instead:


All versions of yii2-di with dependencies

PHP Build Version
Package Version
Requires php Version >=5.6.0
yiisoft/yii2 Version >=2.0.14 <2.1
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 thamtech/yii2-di contains the following files

Loading the files please wait ....