承接 tomrf/autowire 相关项目开发

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

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

tomrf/autowire

Composer 安装命令:

composer require tomrf/autowire

包简介

autowire dependency injection from PSR-11 containers

README 文档

README

PHP Version Require Latest Stable Version License

A simple PHP library that facilitates autowired dependency injection by fetching class constructor dependencies from one or more PSR-11 containers.

Autowire uses the PHP reflection API to peek at constructor parameter types and injects required and optional dependencies from assigned containers.

📔 Go to documentation

Installation

Installation via composer:

composer require tomrf/autowire

Usage

$autowire = new \Tomrf\Autowire\Autowire();

$instance = $autowire->instantiateClass(MyClassWithDependencies::class, $container);

Testing

composer test

License

This project is released under the MIT License (MIT). See LICENSE for more information.

Documentation

📂 Tomrf\Autowire\Autowire::class

Minimal class that facilitates dependency injection by autowiring class constructor dependencies from one or more PSR-11 containers.

resolveDependencies()

Returns array of resolved dependencies for a class constructor.

Dependencies are resolved from one or more PSR-11 containers.

Throws AutowireException if a required dependency could not be met using available containers.

public function resolveDependencies(
    object|string $classOrObject,
    Psr\Container\ContainerInterface $containers
): array

@throws   \Tomrf\Autowire\AutowireException
@return   (null|object)[]

instantiateClass()

Return a new instance of a class after successfully resolving all required dependencies using provided containers.

Throws AutowireException if the class does not exist or if a required dependency could not be met using available containers.

public function instantiateClass(
    string $class,
    Psr\Container\ContainerInterface $containers
): object

@throws   \Tomrf\Autowire\AutowireException

listDependencies()

Returns an array of all dependencies (method parameters) and relevant attributes for a given class or object/callable.

public function listDependencies(
    object|string $classOrObject,
    string $methodName = '__construct'
): array

@throws   \Tomrf\Autowire\AutowireException
@return   array<string,bool|string>[] Array of parameters with attributes

Generated 2022-06-28T01:41:09+02:00 using 📚tomrf/readme-gen

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-10-21

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固