Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ProxyManager #8518

Open
beberlei opened this issue Feb 28, 2021 · 13 comments
Open

Use ProxyManager #8518

beberlei opened this issue Feb 28, 2021 · 13 comments

Comments

@beberlei
Copy link
Member

beberlei commented 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.
@smilesrg
Copy link
Contributor

smilesrg commented 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

@greg0ire
Copy link
Member

greg0ire commented May 2, 2021

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

@smilesrg
Copy link
Contributor

smilesrg commented May 2, 2021

composer update helped, thank you very much!

@beberlei
Copy link
Member Author

@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
Copy link
Member

alcaeus commented 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: doctrine/persistence#145. This will allow a better implementation in ORM without hooking into a number of method calls to resolve proxy class names.

@alcaeus
Copy link
Member

alcaeus commented 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.

@smilesrg
Copy link
Contributor

smilesrg commented 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?

@beberlei
Copy link
Member Author

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 beberlei removed this from the 3.0.0 milestone May 12, 2022
@smilesrg
Copy link
Contributor

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
Copy link
Member

Ocramius commented May 12, 2022 via email

@smilesrg
Copy link
Contributor

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
Copy link
Member

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
Copy link
Member

naderman commented 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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants