doctrine / orm

Doctrine Object Relational Mapper (ORM)
https://www.doctrine-project.org/projects/orm.html
MIT License
9.91k stars 2.51k forks source link

Use ProxyManager #8518

Open beberlei opened 3 years ago

beberlei commented 3 years ago

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

smilesrg commented 3 years ago

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

greg0ire commented 3 years ago

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

smilesrg commented 3 years ago

composer update helped, thank you very much!

beberlei commented 3 years ago

@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.

alcaeus commented 3 years ago

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 3 years ago

@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.

smilesrg commented 2 years ago

@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?

beberlei commented 2 years ago

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.

smilesrg commented 2 years ago

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? :-)

Ocramius commented 2 years ago

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: @.***>

smilesrg commented 2 years ago

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

Ocramius commented 2 years ago

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

naderman commented 11 months ago

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?