Saturday, January 19, 2013

Re: Load different config file

I did it like this:

bootstrap.php

if (isset($_SERVER['SERVER_NAME'])) {
        $tld = strrchr($_SERVER['SERVER_NAME'], ".");
        $tld = substr ($tld, 1);       
    }
    if (!empty($tld)) {
        if ($tld == 'se') {
            Configure::load('config_se');
        }
        elseif ($tld == 'dk') {
            Configure::load('config_dk');
        } else {
            Configure::load('config_no');
        }
    } else {
        Configure::load('config_no');
    }

Anyone have any suggestions on a better approach?


kl. 18:19:07 UTC+1 fredag 18. januar 2013 skrev Andras Kende følgende:
I guess you could do something like:

bootstrap.php

        $tld = strrchr($_SERVER['SERVER_NAME'], '.');
        Configure::load('config' . $tld);

or with parse_url or regex.

Andras Kende
http://www.kende.com


On Jan 18, 2013, at 7:08 AM, MetZ <met...@gmail.com> wrote:

> Hi..
>
> I am wondering the best approach to load different config files according to TLD?
>
> domain.TLD1
> domain.TLD2
> domain.TLD3
>
> config/config_TLD1.php
> config/config_TLD2.php
> config/config_TLD3.php
>
> Today I am using only the config_TLD1.php (loaded in bootstrap).
>
> Any suggestions?
>
> Thanks!
> -Tom
>
> --
> Like Us on FaceBook https://www.facebook.com/CakePHP
> Find us on Twitter http://twitter.com/CakePHP
>  
> ---
> You received this message because you are subscribed to the Google Groups "CakePHP" group.
> To post to this group, send email to cake...@googlegroups.com.
> To unsubscribe from this group, send email to cake-php+u...@googlegroups.com.
> Visit this group at http://groups.google.com/group/cake-php?hl=en.
>  
>  

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: