instantiator README

The project's README from github.com/doctrine/instantiator. As one markdown file: README.md.

Doctrine Instantiator

This library provides a way of avoiding usage of constructors when instantiating PHP classes.

Build Status Code Coverage Dependency Status

Latest Stable Version Latest Unstable Version

Installation

The suggested installation method is via composer:

composer require doctrine/instantiator

Usage

The instantiator is able to create new instances of any class without using the constructor or any API of the class itself:

$instantiator = new \Doctrine\Instantiator\Instantiator();

$instance = $instantiator->instantiate(\My\ClassName\Here::class);

Contributing

Please read the CONTRIBUTING.md contents if you wish to help out!

Credits

This library was migrated from ocramius/instantiator, which has been donated to the doctrine organization, and which is now deprecated in favour of this package.

instantiator (doctrine/instantiator)

Searching Database…

这是什么?Doctrine Instantiator 是一个小型 PHP 库,可以在不调用类的构造函数或该类任何其他方法的情况下,创建该类的新实例。
它是库还是独立工具?它是一个很小的 PHP 库,用来作为 Composer 依赖被其他项目引入,而不是独立的应用程序。
怎样把它加入项目?用 Composer 安装它,然后调用 instantiator 的 API,就能获得任意类的新实例,而不会触发其构造函数。
除了 PHP 和 Composer,还需要别的东西吗?没有列出额外的依赖;安装它只需要 PHP 和 Composer。
通常是谁在用这个库?它主要被其他库和框架使用(例如 Doctrine ORM 以及测试和模拟工具),这些场景需要在绕过构造函数逻辑的情况下创建对象。
为什么要跳过类的构造函数?这在反序列化、模拟(mocking)或 ORM 水合(hydration)等场景中很有用,因为这些场景需要在构造函数参数还未知的情况下先拿到对象实例。
这个项目还在积极维护吗?它归 Doctrine 组织维护,并设有编码规范、静态分析和基准测试的 CI 工作流,说明它仍在积极更新。
它一直都属于 Doctrine 吗?不是,它是从 ocramius/instantiator 包迁移过来的,那个包已捐赠给 Doctrine,现已弃用,改用这个库。
这个库有多大?它是一个非常小、只做单一用途的工具库,自身没有运行时依赖。
What are similar projects?pest, mockery, lexer, voyager, composer, _s, woocommerce, symfony
Which topics is it in?composer, php, testing, library, developer-tools, mit
Creator
doctrine
Size
0.5 MB
Stars
11K
Age
12y
Commits · 90 Days