Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Bogdan Rancichi
@devrck
I have an issue with the proxy generator in version 1
Or that is the design of it :D
You suggested to move to version 2 but that it still not a option for me
Bogdan Rancichi
@devrck
I can "write" the value of a protected attribute without triggering lazy loading
But when i retrieve it
It will trigger the lazy loading even if the value is already set
How can I overcome this behaviour?
Marco Pivetta
@Ocramius
@devckonem I would suggest a functional test for it
see if you can write one that fits your 1.0.x use-case
but remember: I'm not providing anything but security issue fixes for ProxyManager 1.x
Bogdan Rancichi
@devrck
@Ocramius thank you for your suggestion and I understand that you'll only fix security issues :smile:
napestershine
@napestershine
HI I am getting this error on my linux machine
ocramius/proxy-manager 2.0.x-dev requires php 7.0.0 - 7.0.5 || ^7.0.7 -> your PHP version (7.0.6) does not satisfy that requirement
Jefersson Nathan
@malukenho
@napestershine
upgrade your php version to 7.0.7
version 7.0.6 is skipped by ProxyManager due some php internal errors using reflection
napestershine
@napestershine
@malukenho Thakns solved :)
Jefersson Nathan
@malukenho
@napestershine you’re welcome
napestershine
@napestershine
@malukenho how can i downgrade proxy manager version? There is no entry for this in composer.json.
Jefersson Nathan
@malukenho
@napestershine hey! just run composer require on your project, and composer will solve the dependency to a compatible version (if possible), or maybe you have to downgrade all symfony stuff (which can not be cool), my suggestion is to upgrade your php version
napestershine
@napestershine
@malukenho Okay I will try but I am confused :(
Oleksandr Popov
@OlexandrPopov
Hi! Can the library be used to implement caching with smart reference pattern like shown on this sample http://ocramius.github.io/presentations/proxy-pattern-in-php/#/69 ?
Marco Pivetta
@Ocramius
@OlexandrPopov yeah, access interceptor proxies can do that
ProxyManager supports two types of access interceptors
Oleksandr Popov
@OlexandrPopov
@Ocramius Thank you. I found it in the docs.
Roberto Nygaard
@topikito
Hi there! Im new into Gitter, and also just found this Proxy Manager today. I have a question regarding immutability as I see in the examples code with setters. As well, I would also like to know if having private constructors would be a bad practice for this use case.
Marco Pivetta
@Ocramius
@topikito no, you can use private constructors, ProxyManager should honor them
the examples use setters to keep things extremely shallow :)
Roberto Nygaard
@topikito
Thanks @Ocramius
Renato Carvalho
@renatogcarvalho
Hello folks. First of all, thank you for this amazing library @Ocramius and all the contributors. I'm currently using in a Symfony application because I found it very useful to be able to use the AccessorInterceptor proxy to implement some AOP features in a list of services that I have, but after I deployed it in production I noticed that the CPU usage of my servers spiked pretty bad, which I end up having to disable it until I can figure this out. Any ideas on what could cause this? I believe under the hood everything is based on Reflection, but I probably missed something...
Renato Carvalho
@renatogcarvalho
I also tried doing this optimization in AppKernel but it didn't help: https://ocramius.github.io/ProxyManager/docs/tuning-for-production.html
Marco Pivetta
@Ocramius
@renatogcarvalho tricky. If it's a symfony app, you should have the DI container and proxies dumped all in one file
@renatogcarvalho at runtime, not much reflection should go on. At least not enough to make a difference
if you can, run your app (production-alike) through php -dxdebug.profiler_enable_trigger=1 -S localhost:8080 -t public and see where it is hanging.
Renato Carvalho
@renatogcarvalho
Hey @Ocramius sorry for the delayed response. I believe I found what the issue was, but please give me your input when you have a chance. I had some services that were previously defined as "lazy" - which behind the scenes I assume it uses one of your proxy classes - and on top of that I created a factory that was instantiating these services to apply the AccessorInterceptor Proxy. As far as I can tell, the CPU load decreased drastically after I remove all the "lazy" tags from these services. What do you think could have been the issue here? Maybe a circular reference?
Marco Pivetta
@Ocramius
@renatogcarvalho I don't know upfront. Could be runtime codegen though, which means the caching didn't work as expected.
Renato Carvalho
@renatogcarvalho

@Ocramius I had to disable the library again. During peak hours it is not really making a big difference due to the load in our servers. Where would you recommend me to doing the following?

$config = new \ProxyManager\Configuration();
$config->setProxiesTargetDir('/path/to/cache/dir');
spl_autoload_register($config->getProxyAutoloader());

I currently have this set on AppKernel at initializeContainer() but maybe this is not the correct place to do it...

Marco Pivetta
@Ocramius
I'd probably not use $config->getProxyAutoloader(), but rather just add the generated proxies to your classmap and run a composer dump-autoload -o -a
Marco Pivetta
@Ocramius
@renatogcarvalho if this causes the app to crash this means that ProxyManager is generating proxies at runtime
Renato Carvalho
@renatogcarvalho
It doesn't crash but CPU spikes to 100% for long periods of time.
This system I'm referring to has a few API endpoints for some of our applications.
So I couldn't really benchmark using "php -dxdebug.profiler_enable_trigger=1 -S localhost:8080 -t public"
Renato Carvalho
@renatogcarvalho

So you're saying that I show add to the classmap namespaces such as:

ProxyManagerGeneratedProxy__PM__\Namespace\Comes\Here*?

I *should add. typo.
Renato Carvalho
@renatogcarvalho
Well, I guess in classmap you can't really set a namespace. Just trying to understand what you mean by "add the generated proxies to your classmap". Are we talking about the Factories?
Renato Carvalho
@renatogcarvalho

@Ocramius let me know when you have a chance what exactly you mean by "add the generated proxies to your classmap". I tried adding my Factory classes and it didn't help much:

"classmap": [
"app/AppKernel.php",
"app/AppCache.php",
"src/Namespace/To/Factory1/Factory1.php",
"src/Namespace/To/Factory2/Factory2.php",
"src/Namespace/To/Factory3/Factory3.php",
...
]

Marco Pivetta
@Ocramius
@renatogcarvalho no, just "classmap": ["proxy/dir"] and then composer dump-autoload -o -a
Renato Carvalho
@renatogcarvalho
@Ocramius Sorry for my ignorance, but I have no idea what proxy directory you're referring to. Are we talking about the cache directory here?
Marco Pivetta
@Ocramius
@renatogcarvalho well, depends on the app. I'd say we escalate this and we try to figure out what is needed. What I'd need from you is a github issue that:
  • explains your setup
  • explains what was attempted (multiple attempts)
  • we try to fix the docs together
@renatogcarvalho proxy/dir is exactly what it says: the place where proxy classes are dumped