If I understand correctly, you want to load different configurations for each location. The best way to handle this is to set up custom configurations based on the location of the server.
To do this, you can create a custom.php configuration that validates the server name.
$domain = strtolower(@$_SERVER['SERVER_NAME']); switch (true) { default: case 'production.domain.com' == $domain: Configure::write('MyDomain.environment', 'production'); break; case 'staging.domain.com' == $domain: Configure::write('MyDomain.environment', 'staging'); break; case 'local.domain.com' == $domain: case 'mybox.com' == $domain: Configure::write('MyDomain.environment', 'local'); break; }
Now, basically, you can configure the settings based on your environment:
switch (Configure::read('MyDomain.environment')) { default: // for security; wouldn't want any confusion revealing sensitive information case 'production': Configure::write('debug', 0); break; case 'staging': case 'local': Configure::write('debug', 2); break; }
Now you can configure everything anywhere using Configure::write('MyDomain.environment', x) without changing the way the CakePHP files read the kernel.
Happy coding!
source share