Use ProxyManager #6641

Closed
opened 2026-01-22 15:36:19 +01:00 by admin · 14 comments
Owner

Originally created by @beberlei on GitHub (Feb 28, 2021).

We can replace our own proxy generator with https://github.com/FriendsOfPHP/proxy-manager-lts in two steps:

  • Replace current behavior 1:1. This should target the next 2.x branch already and work alongside the existing proxy code, so that usres can choose. Use the Mongo ODM as example, they moved to proxy manager already. Tricky bits will be how to make sure something like getClassMetadata(get_class($proxy)), which needs a resolver or something alike.
  • Add support for lazy loading single columns later than the whole entity such as large clobs/blobs.
Originally created by @beberlei on GitHub (Feb 28, 2021). We can replace our own proxy generator with https://github.com/FriendsOfPHP/proxy-manager-lts in two steps: - Replace current behavior 1:1. This should target the next 2.x branch already and work alongside the existing proxy code, so that usres can choose. Use the Mongo ODM as example, they moved to proxy manager already. Tricky bits will be how to make sure something like `getClassMetadata(get_class($proxy))`, which needs a resolver or something alike. - Add support for lazy loading single columns later than the whole entity such as large clobs/blobs.
admin added the Improvement label 2026-01-22 15:36:19 +01:00
admin closed this issue 2026-01-22 15:36:20 +01:00
Author
Owner

@smilesrg commented on GitHub (May 2, 2021):

composer require friendsofphp/proxy-manager-lts
composer require -W friendsofphp/proxy-manager-lts

Leads to an error:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Root composer.json requires doctrine/coding-standard ^9.0, found doctrine/coding-standard[9.0.0] but the package is fixed to 8.2.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
  Problem 2
    - Root composer.json requires vimeo/psalm 4.7.0, found vimeo/psalm[4.7.0] but the package is fixed to 4.3.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.

/cc @beberlei @greg0ire

@smilesrg commented on GitHub (May 2, 2021): `composer require friendsofphp/proxy-manager-lts` `composer require -W friendsofphp/proxy-manager-lts` Leads to an error: ``` Your requirements could not be resolved to an installable set of packages. Problem 1 - Root composer.json requires doctrine/coding-standard ^9.0, found doctrine/coding-standard[9.0.0] but the package is fixed to 8.2.1 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. Problem 2 - Root composer.json requires vimeo/psalm 4.7.0, found vimeo/psalm[4.7.0] but the package is fixed to 4.3.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command. ``` /cc @beberlei @greg0ire
Author
Owner

@greg0ire commented on GitHub (May 2, 2021):

It works for me on b2f404b25 . Have you run composer update beforehand?

@greg0ire commented on GitHub (May 2, 2021): It works for me on b2f404b25 . Have you run `composer update` beforehand?
Author
Owner

@smilesrg commented on GitHub (May 2, 2021):

composer update helped, thank you very much!

@smilesrg commented on GitHub (May 2, 2021): `composer update` helped, thank you very much!
Author
Owner

@beberlei commented on GitHub (May 14, 2021):

@alcaeus brought to my attention that our old prototype branch has done this also: https://github.com/doctrine/orm/blob/old-prototype-3.x/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php - This could be used as a starting point, sorry I didn't see this before.

@beberlei commented on GitHub (May 14, 2021): @alcaeus brought to my attention that our old prototype branch has done this also: https://github.com/doctrine/orm/blob/old-prototype-3.x/lib/Doctrine/ORM/Proxy/Factory/StaticProxyFactory.php - This could be used as a starting point, sorry I didn't see this before.
Author
Owner

@alcaeus commented on GitHub (May 14, 2021):

Tricky bits will be how to make sure something like getClassMetadata(get_class($proxy)), which needs a resolver or something alike.

We've had issues around that in ODM. We worked around it, but the upcoming release of doctrine/persistence includes configurable resolvers: https://github.com/doctrine/persistence/pull/145. This will allow a better implementation in ORM without hooking into a number of method calls to resolve proxy class names.

@alcaeus commented on GitHub (May 14, 2021): > Tricky bits will be how to make sure something like `getClassMetadata(get_class($proxy))`, which needs a resolver or something alike. We've had issues around that in ODM. We worked around it, but the upcoming release of doctrine/persistence includes configurable resolvers: https://github.com/doctrine/persistence/pull/145. This will allow a better implementation in ORM without hooking into a number of method calls to resolve proxy class names.
Author
Owner

@alcaeus commented on GitHub (May 14, 2021):

@smilesrg please feel free to contact me in either Symfony or Doctrine Slack if you have question. I took @Ocramius' original implementation when adding this feature to MongoDB ODM and learned a number of things that didn't work along the way. I'd be happy to help you get this done.

@alcaeus commented on GitHub (May 14, 2021): @smilesrg please feel free to contact me in either Symfony or Doctrine Slack if you have question. I took @Ocramius' original implementation when adding this feature to MongoDB ODM and learned a number of things that didn't work along the way. I'd be happy to help you get this done.
Author
Owner

@smilesrg commented on GitHub (Oct 16, 2021):

@beberlei @alcaeus I tried to get back to this issue, but I'm not sure what should I do and where to start. Probably I need to replace the proxy factory in the EntityManager? Also, change all places that are using EntityManagerInterface::getProxyFactory()? What should be used instead of AbstractProxyFactory methods?

@smilesrg commented on GitHub (Oct 16, 2021): @beberlei @alcaeus I tried to get back to this issue, but I'm not sure what should I do and where to start. Probably I need to replace the proxy factory in the [EntityManager](https://github.com/doctrine/orm/blob/2e86134c0b4a483db25bb964c65ced5bc8a22252/lib/Doctrine/ORM/EntityManager.php#L163)? Also, change all places that are using [EntityManagerInterface::getProxyFactory()]( https://github.com/doctrine/orm/blob/dede619b9eb376c1829df17908476f9416f295c6/lib/Doctrine/ORM/EntityManagerInterface.php#L306)? What should be used instead of [AbstractProxyFactory](https://github.com/doctrine/common/blob/3.1.x/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php) methods?
Author
Owner

@beberlei commented on GitHub (May 12, 2022):

We should detach this from a milestone for now, effectively unscheduling it, since the ProxyGenerator is under our control and the last 2 years have shown that proxy-manager cannot keep up with new features in PHP releases quickly enough for us.

@beberlei commented on GitHub (May 12, 2022): We should detach this from a milestone for now, effectively unscheduling it, since the `ProxyGenerator` is under our control and the last 2 years have shown that proxy-manager cannot keep up with new features in PHP releases quickly enough for us.
Author
Owner

@smilesrg commented on GitHub (May 12, 2022):

the ProxyGenerator is under our control and the last 2 years have shown that proxy-manager cannot keep up with new features in PHP releases quickly enough for us.

Why not make a fork? :-)

@smilesrg commented on GitHub (May 12, 2022): >the ProxyGenerator is under our control and the last 2 years have shown that proxy-manager cannot keep up with new features in PHP releases quickly enough for us. Why not make a fork? :-)
Author
Owner

@Ocramius commented on GitHub (May 12, 2022):

Why not help out instead? I'm not paid to work on it, y'know? 😛

On Thu, 12 May 2022, 12:30 Serhii Smirnov, @.***> wrote:

the ProxyGenerator is under our control and the last 2 years have shown
that proxy-manager cannot keep up with new features in PHP releases quickly
enough for us.

Why not make a fork? :-)


Reply to this email directly, view it on GitHub
https://github.com/doctrine/orm/issues/8518#issuecomment-1124828001, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AABFVEDE7KBY5LPOS46KZ4DVJTMVPANCNFSM4YLRDTWQ
.
You are receiving this because you were mentioned.Message ID:
@.***>

@Ocramius commented on GitHub (May 12, 2022): Why not help out instead? I'm not paid to work on it, y'know? 😛 On Thu, 12 May 2022, 12:30 Serhii Smirnov, ***@***.***> wrote: > the ProxyGenerator is under our control and the last 2 years have shown > that proxy-manager cannot keep up with new features in PHP releases quickly > enough for us. > > Why not make a fork? :-) > > — > Reply to this email directly, view it on GitHub > <https://github.com/doctrine/orm/issues/8518#issuecomment-1124828001>, or > unsubscribe > <https://github.com/notifications/unsubscribe-auth/AABFVEDE7KBY5LPOS46KZ4DVJTMVPANCNFSM4YLRDTWQ> > . > You are receiving this because you were mentioned.Message ID: > ***@***.***> >
Author
Owner

@smilesrg commented on GitHub (May 12, 2022):

Why not help out instead?

I'd help, but I think some roadmap is needed because I don't know what exactly Doctrine project needs

@smilesrg commented on GitHub (May 12, 2022): >Why not help out instead? I'd help, but I think some roadmap is needed because I don't know what exactly Doctrine project needs
Author
Owner

@Ocramius commented on GitHub (May 12, 2022):

See https://github.com/Ocramius/ProxyManager/milestone/56

Effectively it's just about supporting newer PHP versions, and PHP 8.1 has been a nightmare to upgrade to, with some of the libraries I co-maintain taking multiple months of work just to get there.

In practice, PHP 8.1 is probably the worst release I've dealt with yet :P

@Ocramius commented on GitHub (May 12, 2022): See https://github.com/Ocramius/ProxyManager/milestone/56 Effectively it's just about supporting newer PHP versions, and PHP 8.1 has been a nightmare to upgrade to, with some of the libraries I co-maintain taking multiple months of work just to get there. In practice, PHP 8.1 is probably the worst release I've dealt with yet :P
Author
Owner

@naderman commented on GitHub (Oct 2, 2023):

So PARTIAL has been marked deprecated for a while. In how far can we rely on PARTIAL staying around until lazy loading for 1:1 relationships is implemented as suggested here?

@naderman commented on GitHub (Oct 2, 2023): So PARTIAL has been marked deprecated for a while. In how far can we rely on PARTIAL staying around until lazy loading for 1:1 relationships is implemented as suggested here?
Author
Owner

@beberlei commented on GitHub (Oct 6, 2025):

Not needed anymore as we moved towards using native lazy objects in PHP 8.4 - this also undeprecated partial objects as we can use them again with partial lazy object loading in the future.

@beberlei commented on GitHub (Oct 6, 2025): Not needed anymore as we moved towards using native lazy objects in PHP 8.4 - this also undeprecated partial objects as we can use them again with partial lazy object loading in the future.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6641