Doctrine 2. Proxy auto-generation

I have a strange problem. I want to disable the auto-generation of my proxies in Doctrine 2. I found this line of code that should do (and does) the trick:

$config->setProxyDir(APPPATHSYSTEM."/proxies"); $config->setProxyNamespace('Proxies'); // Auto generate proxies for development $config->setAutoGenerateProxyClasses(DEVELOPMENT); 

In my test environment, proxies are located in the application / proxy. i.e:.

 application/proxies/BaseUserProxy.php 

When I am in a live environment, my code suddenly looks for proxies in an application / proxy / Proxy, which is not the actual location.

I understand that this has something to do with the namespace, but I don't understand why it behaves differently when using the setAutoGenerateProxy method.

Any ideas?

change

I created new proxies with:

 orm:generate-proxies 

option.

Which gave me this result:

 php doctrine.php orm:generate-proxies Processing entity "Base\Element" Processing entity "Base\Page" ... Processing entity "Base\Site" Proxy classes generated to "/var/www/application/proxies" 

Looking at the last line, proxies are generated in / var / www / application / proxies. The list of directories is as follows:

 BaseElementProxy.php BasePageProxy.php ... BaseSiteProxy.php 

Therefore, there is no additional Proxies directory. But when I refresh my web page, she thinks she is, she gives me the following error:

 Warning: require(/var/www/application//proxies/Proxies/BaseUserProxy.php) [function.require]: failed to open stream: No such file or directory in /var/www/library/Doctrine/Common/ClassLoader.php on line 148 

Why is the optional Proxies directory added? If I create a proxy on every request, it does not look in the additional Proxies directory. Is anyone

@Bryan M .. This is not a solution, but a workaround. In addition, it does not work. When creating proxies, they will, if your suggestions are applied, be created in APPPATHSYSTEM, and my webapp will try to download them from APPPATHSYSTEM. "Proxy". The problem is that the system is looking for proxies in different places if I use:

 $config->setAutoGenerateProxyClasses(DEVELOPMENT); 

If DEVELOPMENT is true, he will watch APPPATHSYSTEM. If DEVELOPMENT is set to false, it will watch APPPATHSYSTEM. "Proxy". Just switching the DEVELOPMENT constant breaks my application, which theoretically should not be possible.

+9
php orm doctrine2
Nov 04 '10 at 11:12
source share
3 answers

Do you work on OS X and deploy Linux? The OS X file system is case insensitive. Therefore, I often encounter a problem when I am mistaken in the case of a class, and it works and runs fine in the local environment, but suffocates on our server.

Thus, in this case, the namespace "Proxy" in OS X can resolve "/ proxies", but during production it cannot find the class folder and creates it under "/ proxies / Proxies" ,.

+4
Nov 04. '10 at 20:08
source share

If you rename the folder to something called "/ temp", you will understand the difference between empty and namespace.

The path is the absolute path to the directory into which the proxies are generated. The namespace is necessary so that you can configure how autoloaders load these objects.

The path in your case should be something like "proxies / Proxies", and the namespace should be "Proxies". Your autoloader must be configured to listen for the proxy namespace prefix in the proxies / directory.

This is all the mood with Doctrine 2 RC1, but we found a way to explicitly load the proxy path without the help of the autoloader at no additional cost. Therefore, the proxy server namespace configuration only needs to be sure that other classes are not in the same namespace as the proxy.

+3
Nov 16 '10 at 13:12
source share

I do not think leaving with an AutoGenerated proxy.

Instead of pushing auto- doctrine orm:generate-proxies to production, you probably should doctrine orm:generate-proxies , which I suspect put them in the place where your production code is configured to search for them.

+2
Nov 04 '10 at 18:01
source share



All Articles