Download the PHP package yjx/easy-di without Composer

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

EasyDI

EasyDI是一个具有自动依赖注入的小型容器, 遵循PSR-11.

具体详细介绍及讨论请参见blog


容器提供方法:

安装 Installation

Install EasyDi with Composer

composer require yjx/easy-di

基础使用 Basic Usage

容器的实例化

EasyDI容器管理两种类型的数据: 服务 和 参数(raw)

定义服务和参数

闭包中的参数$c由于使用了类型指示, 因此EasyDI会自动完成依赖注入(将它自身注入).

自动依赖解决

示例1

直接拿PHP-DI官方演示代码

示例2

示例3 call()

php class UserManager { private $mailer;

public function __construct(Mailer $mailer)
{
    $this->mailer = $mailer;
}

public function register($email, $password)
{
    // The user just registered, we create his account
    // ...

    // We send him an email to say hello!
    $this->mailer->mail($email, 'Hello and welcome!');
}

public function quickSend(Mailer $mailer, $email, $password)
{
    $mailer->mail($email, 'Hello and welcome!');
}

}

function testFunc(UserManager $manager) { return "test"; }

// 实例化容器 $c = new EasyDI\Container();

// 输出: 'test' echo $c->call('testFunc')."\n";

// 输出: 'test' echo $c->call(function (UserManager $tmp) { return 'test'; });

// 自动实例化UserManager对象 [$className, $methodName] $c->call([UserManager::class, 'register'], ['password'=>123, 'email'=>'[email protected]']);

// 自动实例化UserManager对象 $methodFullName $c->call(UserManager::class.'::'.'register', ['password'=>123, 'email'=>'[email protected]']);

// 调用类的静态方法 [$className, $staticMethodName] $c->call([UserManager::class, 'quickSend'], ['password'=>123, 'email'=>'[email protected]']);

// 使用字符串调用类的静态方法 $staticMethodFullName $c->call(UserManager::class.'::'.'quickSend', ['password'=>123, 'email'=>'[email protected]']);

// [$obj, $methodName] $c->call([new UserManager(new Mailer()), 'register'], ['password'=>123, 'email'=>'[email protected]']);

// [$obj, $staticMethodName] $c->call([new UserManager(new Mailer()), 'quickSend'], ['password'=>123, 'email'=>'[email protected]']);


All versions of easy-di with dependencies

PHP Build Version
Package Version
Requires psr/container Version ^1.0
php Version ^5.4 || ^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 yjx/easy-di contains the following files

Loading the files please wait ....