承接 loomsoftware/dependency-injection-component 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

loomsoftware/dependency-injection-component

最新稳定版本:1.0.5

Composer 安装命令:

composer require loomsoftware/dependency-injection-component

包简介

A PSR compliant dependency injection library for PHP.

README 文档

README

Version 1.0.5 Coverage 93.75% License GPL-3.0-or-later

A PHP package for managing dependencies and dependency injection.

Installation

You can install this package via Composer:

composer require loomsoftware/dependency-injection-component

Usage

DependencyContainer

The DependencyContainer class provides a simple way to manage and retrieve dependencies. You can add and retrieve dependencies as follows:

use Loom\DependencyInjectionComponent\DependencyContainer;

// Create a container
$container = new DependencyContainer();

// Add a dependency
$container->add(MyDependency::class, new MyDependency());

// Retrieve a dependency
$dependency = $container->get(MyDependency::class);

DependencyManager

The DependencyManager class allows you to load dependencies from a YAML configuration file and register them in a DependencyContainer. Here's an example of how to use it:

use Loom\DependencyInjectionComponent\DependencyContainer;
use Loom\DependencyInjectionComponent\DependencyManager;

// Create a container
$container = new DependencyContainer();

// Create a manager and load dependencies from a YAML file
$manager = new DependencyManager($container);
$manager->loadDependenciesFromFile('path/to/dependencies.yaml');

In your YAML configuration file (dependencies.yaml), you can define services and their arguments for injection.

Setting Up Your Services/Dependencies Definitions

Here's an example of a dependencies.yaml file that demonstrates how to define services and their arguments for injection:

services:
  myService:
    class: 'Namespace\MyService'
    arguments:
      - 'argument1'
      - 'argument2'
      - '@anotherService'  # Inject another service

Here's a breakdown of the elements in the dependencies.yaml file:

  • services: This section defines the services and their configurations.
  • alias: Your chosen alias for the service - myService.
  • class: The fully qualified class name of the service class.
  • arguments: An array of constructor arguments. Use "@" to reference other services.

Once you've set up your dependencies.yaml file with the desired services and configurations, you can load and manage these dependencies using the Dependency Injection Package.

License

This package is open-source software licensed under the GNU General Public License, version 3.0 (GPL-3.0).

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2025-05-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固