Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7e7fce1

Browse files
committed
Update doc for real object managers
1 parent 87c4f30 commit 7e7fce1

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

‎README.md‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,31 @@ This extension provides following features:
1212
* Provides correct return type for `Doctrine\ORM\EntityManager::find`, `getReference` and `getPartialReference` when `Foo::class` entity class name is provided as the first argument
1313
* Adds missing `matching` method on `Doctrine\Common\Collections\Collection`. This can be turned off by setting `parameters.doctrine.allCollectionsSelectable` to `false`.
1414

15-
This extension does not yet support custom `repositoryClass` specified for each entity class. However, if your repositories have a common base class, you can configure it in your `phpstan.neon` and PHPStan will see additional methods you define in it:
15+
If your repositories have a common base class, you can configure it in your `phpstan.neon` and PHPStan will see additional methods you define in it:
1616

17-
```
17+
```neon
1818
parameters:
1919
doctrine:
2020
repositoryClass: MyApp\Doctrine\BetterEntityRepository
2121
```
2222

23+
Alternatively, you can provide your object manager and all custom repositories will be loaded
24+
25+
```neon
26+
parameters:
27+
doctrine:
28+
objectManagerLoader: tests/object-manager.php
29+
```
30+
31+
For example, in a Symfony project, `object-manager.php` would look something like this:
32+
33+
```php
34+
require dirname(__DIR__).'/../config/bootstrap.php';
35+
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
36+
$kernel->boot();
37+
return $kernel->getContainer()->get('doctrine')->getManager();
38+
```
39+
2340
## Usage
2441

2542
To use this extension, require it in [Composer](https://getcomposer.org/):

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /