0

I am trying to figure out where to setup my memcached configuration in CakePHP 2. Both core.php and bootstrap.php have sections to set up any cache such as memcached, but I still haven't figured out which file to use.

Also the CakePHP documentation is not so clear about this in my eyes. Could anyone point out what part of the memcached configuration goes into which file please.

1 Answer 1

3

Really, you can place configuration values anywhere you would like, even in their own files as long as you load them in core.php or bootstrap.php. However, the default 2.0 core.php file states that other cache configurations should be in bootstrap.php as stated here: https://github.com/cakephp/cakephp/blob/master/app/Config/core.php#L349.

FWIW, we load addition configuration files depending on an environment variable (APP_ENV) as well as a location specific one that overrides all others. We call it core-local.php but the name doesn't really matter as long as it's not tracked in your VCS.

Edit:

Here's how we load environment specific configs. This is towards the end of our core.php so that the configs loaded after it are not overwritten.

$env = getenv('APP_ENV');
if (is_readable(dirname(__FILE__) . "/core-{$env}.php")) {
  Configure::load("core-{$env}");
}

End Edit

Lastly, the CakePHP docs are really easy to edit and PRs are very welcome. If you think you can clarify the docs just click on the link at the top of the documentation page and edit away. You can then use the GitHub UI to submit the PR. No editor or git binary is necessary.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi @alecho, thanks for the answer. Clearer now, but I am still not 100 percent sure yet. Could you please tell me in which file you include your custom config and how. Thank you very much
@lockdoc I updated my answer with an example of loading environment specific configs in CakePHP. This allows you to have different configs, including those for Memcached, for development, staging, and production (as well as any others you may need) environments.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.