Download the PHP package fanqingxuan/di without Composer

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

中文文档地址

a IOC container for php

This is a extension which implements Dependency Injection, it's itself a container and it implements the

Inversion of Control pattern.

enviroment requirement

php7.0+

Install

If you want install it as php extension, please see di-ext. The same usage with this package.

Basic Usage

like you can see,there are serveral ways to register services as the follow list.

You can pass additonal parameters to closure function.

also,you can pass parameter by using the key word of use.

Advanced Usage

Some class have setters for injection with their specail demand. We modify the above service as the class with setters.

A service with setter injection can be registered as follows:

A service with properties injection can be registered as follows

More Advanced Usage

The next we will give a way that inject service from php file.

We can inject it to container as follows:

Array Syntax Usage

We introduce the usage with the set function above. In fact,the array syntax is also allowed to register as services.

Property Syntax Usage

We can inject the object with the property usage. Actually,it use the magic methd to realize it.

Get Services

Shared Services

Services can be registered as ‘shared’ services this means that they always will act as singletons. Once the service is resolved for the first time the same instance of it is returned every time.

or use the set method with its third parameter as 'true'.

Modify the Services

When the service is registered in the container,you can get it and modify it.

Automatic Inject the DI Container into the service

DI Container is used for inject other service into it. but sometimes the service itself need the the other instance from the container. If a class or component requires the DI itself to locate services, the DI can automatically inject itself to the instances it creates, to do this, you need to extends the JsonDi\Di\AbstractInjectionAware class in your classes:

Service Providers

Using the JsonDi\Di\ServiceProviderInterface you now register services by context. You can move all your $di->set() calls to classes as follows. Notice return void for the register function.


All versions of di with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 fanqingxuan/di contains the following files

Loading the files please wait ....