Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Marco Pivetta
@Ocramius
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
Renato Carvalho
@renatogcarvalho
@Ocramius I'm going to create a detailed issue on Github and share with you sometime today. Thank you!
Bram Van der Sype
@Brammm

Hi, I’d like to use ProxyManager to add a PrefixInterceptor on a Doctrine entity that will load some data from an external API (most of the entity data comes from mysql, but one VO is loaded from Stripe). We however use YAML mapping and now Doctrine is confused, spitting out the following: No mapping file found named 'ProxyManagerGeneratedProxy.__PM__.Account.Generated057e19f64f9522d6b31349e983c34acc.dcm.yml' for class 'ProxyManagerGeneratedProxy\__PM__\Account\Generated057e19f64f9522d6b31349e983c34acc

Anyone got any ideas on how to fix that?

Bram Van der Sype
@Brammm
I’ve had the realization that I should probably proxy the VO I want to lazy load, and not the entity
Marco Pivetta
@Ocramius
@Brammm I don't think that the ORM can play with ProxyManager proxies at all
because it uses get_class() all over the place. This might work with doctrine/orm:dev-master, but I didn't try
Bram Van der Sype
@Brammm
interesting
Marco Pivetta
@Ocramius
I'd probably use a postLoad listener in the ORM instead
Bram Van der Sype
@Brammm
yeah, I’ll see if I can do anything with the lifecycle callbacks and a proxy maybe.
indeed.
Marco Pivetta
@Ocramius
The ORM will still try reading into your VO, so it might not work at all
charlieman
@charlieman
Hello, I'm getting this error Uncaught Error: Call to undefined method PhpAmqpLib\Channel\AMQPChannel::__destruct() in /srv/app/vendor/ocramius/proxy-manager/src/ProxyManager/GeneratorStrategy/EvaluatingGeneratorStrategy.php(68) : eval()'d code:42
is there a way to let ProxyManager know the class doesn't have a destructor?
charlieman
@charlieman
I'm checking the ReflectionClass for that class and getMethods doesn't return __destruct
Marco Pivetta
@Ocramius
Dtor should only be generated if there is a dtor. Can you use the file writer generator strategy and check the generated code please?
Also, what version are you running? Upgraded to latest?
charlieman
@charlieman
@Ocramius I'm using 2.0.4 because the server has php 7.0, also version 3.1.0 of zend-code and 1.2.0 of package-version
I'll try to use the file writer and get back
Marco Pivetta
@Ocramius
You'll need to upgrade to the latest version before asking for help, heh
Gytis Šk.
@gskema
Hello, anyone here ?
Gytis Šk.
@gskema
Release 2.2.0 says "PHP 7.1 support has been dropped.", but there is no commit link.
I see now that composer.json requires ^7.2, but it would still be interesting to see why this was changed.
Marco Pivetta
@Ocramius
@gskema yeah, it was done as part of generic upgrades. I always drop compatibility with older versions of all dependencies on a regular basis in order to reduce the amount of maintenance work, and in order to allow everyone to start using new features.
Gytis Šk.
@gskema
ok, thanks. I just put it ^2.0 in composer.json, it will select the correct version based on PHP version.
Marco Pivetta
@Ocramius
yup, be aware that I'll likely release 3.0 with 7.3 support only
Gytis Šk.
@gskema
Hello, I am using AccessInterceptorValueHolderFactory
I would like to intercept all methods, what is the correct way to do that? I tried using setMethodPrefixInterceptor but it only matches exact method names
Gytis Šk.
@gskema
@Ocramius
Gytis Šk.
@gskema
OK, so I assume prefix means "pre-exec" and suffix means "post-exec", no method name str matching. I guess I will use ReflectionClass to register interceptors for all methods
Marco Pivetta
@Ocramius

what is the correct way to do that?

You'd need to use (new ReflectionClass())->getMethods() and use that to pre-fill those arrays

and yes, this came up in the past: it is the correct way to do it :)
Gytis Šk.
@gskema
That's exactly what I did. Thanks @Ocramius
Volkan Ulukut
@Seldar
It seems there is no support for php 7.3. Any plans to release a version for 7.3?
Marco Pivetta
@Ocramius
@Seldar ^2.2 supports "php": "^7.2"