| 148 |
lars |
1 |
# Instantiator
|
|
|
2 |
|
|
|
3 |
This library provides a way of avoiding usage of constructors when instantiating PHP classes.
|
|
|
4 |
|
|
|
5 |
[](https://travis-ci.org/doctrine/instantiator)
|
|
|
6 |
[](https://codecov.io/gh/doctrine/instantiator/branch/master)
|
|
|
7 |
[](https://www.versioneye.com/package/php--doctrine--instantiator)
|
|
|
8 |
|
|
|
9 |
[](https://packagist.org/packages/doctrine/instantiator)
|
|
|
10 |
[](https://packagist.org/packages/doctrine/instantiator)
|
|
|
11 |
|
|
|
12 |
## Installation
|
|
|
13 |
|
|
|
14 |
The suggested installation method is via [composer](https://getcomposer.org/):
|
|
|
15 |
|
|
|
16 |
```sh
|
|
|
17 |
composer require doctrine/instantiator
|
|
|
18 |
```
|
|
|
19 |
|
|
|
20 |
## Usage
|
|
|
21 |
|
|
|
22 |
The instantiator is able to create new instances of any class without using the constructor or any API of the class
|
|
|
23 |
itself:
|
|
|
24 |
|
|
|
25 |
```php
|
|
|
26 |
$instantiator = new \Doctrine\Instantiator\Instantiator();
|
|
|
27 |
|
|
|
28 |
$instance = $instantiator->instantiate(\My\ClassName\Here::class);
|
|
|
29 |
```
|
|
|
30 |
|
|
|
31 |
## Contributing
|
|
|
32 |
|
|
|
33 |
Please read the [CONTRIBUTING.md](CONTRIBUTING.md) contents if you wish to help out!
|
|
|
34 |
|
|
|
35 |
## Credits
|
|
|
36 |
|
|
|
37 |
This library was migrated from [ocramius/instantiator](https://github.com/Ocramius/Instantiator), which
|
|
|
38 |
has been donated to the doctrine organization, and which is now deprecated in favour of this package.
|