سؤال

I have a CakePHP installation with multiple apps that has this structure:

/cake-1.3.10 /cake-2.3.0 /apps/app 1 /apps/app 2 /... /apps/app N /apps/_shared/Cake_v1/Component /apps/_shared/Cake_v1/Model /apps/_shared/Cake_v2/Component /apps/_shared/Cake_v2/Model

So what happens here is that all the apps grab the v1.3 or v2.3 cores (depending on which version of the framework they use). In addition, I have some Components and Models that all the apps share. Each app loads those from the _shared folder depending on its version.

Until here all works great.

Now, I would like to do the same for the database configuration. Each app has its own /config/database.php file. How would I go about making it so ALL apps share the same database.php file? Actually I would have 2 database.php files, one per version, since they're different (like with Components and Models). But I'm not sure what exactly I need to change to accomplish that.

هل كانت مفيدة؟

المحلول

I don't see that there is easy CakePHP way. You have to modify /lib/Cake/Model/ConnectionManager.php . In version 2.3 on line 69 there is

include_once APP . 'Config' . DS . 'database.php';

I don't see there any code that allows the configuration. It looks hardcoded.

More elegant way is that you make symbolic links as @Kai mentioned. Then you can upgrade CakePHP without having to remember about your little hack.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top