How to make confg file local.php overwrite global.php (instead of merging it)?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to make confg file local.php overwrite global.php (instead of merging it)?

Julian Vidal
I have a situation in which an app is deployed into Amazon Beanstalk,
Rackspace, and of course the local development environments. As it turns
out, each environment will use a different cache adapter (Rackspace and
Amazon will use memcached, and development will use filesystem).

My global.php file has the filesystem cache configured and as I deploy into
each environment there is a script that copies different cache.local.php
files in place for each environment.

My problem is that these files are being merged and I end up with a config
array with keys for both adapters. So I get errors like "The option
"cache_dir" does not have a matching setCacheDir setter method which must
be defined". These errors are correct because the Memcached adapter does
not have a setCacheDir() method; it's a leftover from the cache.global.php
which uses a Filesystem adapter.

The only solution that I can think of is having a single cache.global.php
and replacing that file entirely in each environment.

Are there any good practices related to this?

Thanks
Reply | Threaded
Open this post in threaded view
|

Re: How to make confg file local.php overwrite global.php (instead of merging it)?

jmleroux
If this is environment specific, why is it configured in global.php ?

Your *.local.php should be enough.


Le 07/02/2014 22:56, Julian Vidal a écrit :

> I have a situation in which an app is deployed into Amazon Beanstalk,
> Rackspace, and of course the local development environments. As it turns
> out, each environment will use a different cache adapter (Rackspace and
> Amazon will use memcached, and development will use filesystem).
>
> My global.php file has the filesystem cache configured and as I deploy into
> each environment there is a script that copies different cache.local.php
> files in place for each environment.
>
> My problem is that these files are being merged and I end up with a config
> array with keys for both adapters. So I get errors like "The option
> "cache_dir" does not have a matching setCacheDir setter method which must
> be defined". These errors are correct because the Memcached adapter does
> not have a setCacheDir() method; it's a leftover from the cache.global.php
> which uses a Filesystem adapter.
>
> The only solution that I can think of is having a single cache.global.php
> and replacing that file entirely in each environment.
>
> Are there any good practices related to this?
>
> Thanks
>

--
JM Leroux

https://github.com/jmleroux


--
List: [hidden email]
Info: http://framework.zend.com/archives
Unsubscribe: [hidden email]


Reply | Threaded
Open this post in threaded view
|

Re: How to make confg file local.php overwrite global.php (instead of merging it)?

Artur Bodera
In reply to this post by Julian Vidal
On Fri, Feb 7, 2014 at 10:56 PM, Julian Vidal <[hidden email]>wrote:

> My problem is that these files are being merged and I end up with a config
> array with keys for both adapters.
>

Yeah, that's the drawback of config merging.

Better keep the whole config sub-array separate... try to use the fact,
that you can have any number of config files which will get merged, so you
can have templates like:

- cache.rackspace.local.php.dist
- cache.beanstalk.local.php.dist
- cache.devel.local.php.dist

Or even go with adapter-specific config, for example:

- cache.apc.local.php.dist
- cache.memcached.local.php.dist
- ...


... and then you'd just have your scripts copy the appropriate *.dist file
in place on each instance.

Hope that helps.

Art.


--
[hidden email]
+48 695 600 936
http://thinkscape.pro
Reply | Threaded
Open this post in threaded view
|

Re: How to make confg file local.php overwrite global.php (instead of merging it)?

Julian Vidal
Thanks, I'll follow your advice.


On Sun, Feb 9, 2014 at 10:36 AM, Artur Bodera <[hidden email]> wrote:

>
> On Fri, Feb 7, 2014 at 10:56 PM, Julian Vidal <[hidden email]>wrote:
>
>> My problem is that these files are being merged and I end up with a config
>> array with keys for both adapters.
>>
>
> Yeah, that's the drawback of config merging.
>
> Better keep the whole config sub-array separate... try to use the fact,
> that you can have any number of config files which will get merged, so you
> can have templates like:
>
> - cache.rackspace.local.php.dist
> - cache.beanstalk.local.php.dist
> - cache.devel.local.php.dist
>
> Or even go with adapter-specific config, for example:
>
> - cache.apc.local.php.dist
> - cache.memcached.local.php.dist
> - ...
>
>
> ... and then you'd just have your scripts copy the appropriate *.dist file
> in place on each instance.
>
> Hope that helps.
>
> Art.
>
>
> --
> [hidden email]
> +48 695 600 936
> http://thinkscape.pro
>