progphil1337/php-di 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

progphil1337/php-di

最新稳定版本:v1.0.0

Composer 安装命令:

composer require progphil1337/php-di

包简介

Simple but effective dependency injection library

README 文档

README

Simple but effective dependency injection library

Installation

Install with composer:

$ composer require progphil1337/php-di

Compatibility

ProgPhil1337\DependencyInjection requires PHP 8.1 (or better).

Usage

Basic example

ExampleForm.php

use ProgPhil1337\DependencyInjection\ClassLookup;
use ProgPhil1337\DependencyInjection\Injector;

use MyApp\YamlConfig;
use MyApp\AbstractConfig;
use MyApp\SingletonInterface;

$lookup = new ClassLookup();
$injector = new Injector($lookup);

$lookup
    // class aliases
    ->alias(YamlConfig::class, AbstractConfig::class)

    // register singletons
    ->singleton(SingletonInterface::class)

    // Register classes that cannot be created
    ->register(new YamlConfig()) 
;

// Example for alias and registering
$yamlConfig = $injector->create(AbstractConfig::class);

统计信息

  • 总下载量: 195
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-09-15