I saw this somewhere so I won't claim credit, but this how I do it.
You just have to change one value in core.php after implementing this
system. Since Configure::read is usable from views too, you can set
paths for javascripts like lightbox or other application elements
without hunting for changes after each commit.

Don't define $default in database.php and put the following at the
bottom of database.php:
function __construct() {
                switch(Configure::read('WebApp.mode')) {
                        case "mamp":
                                $this->default = $this->mamp;
                                $this->test = $this->test_mamp;
                                break;
                        case "devel":
                        case "linode":
                                $this->default = $this->devel;
                                $this->test = $this->test_devel;
                                break;
                        default:
                        case "production":
                                $this->default = $this->production;
                                $this->test = $this->test_production;
                                break;
                } // end switch
        } // end construct()


Next, in core.php add the following:
Configure::write('WebApp.mode', 'devel'); # 'devel', 'production',
'linode', 'mamp'
if(Configure::read('WebApp.mode') == 'production') { Configure::write
('debug', 0); }

On Feb 10, 11:22 pm, travisbeck <[email protected]> wrote:
> that's what i had planned on doing.  I just hoped there was a cleaner
> way. thanks for the help though.
>
> On Feb 10, 10:12 pm, Adam Royle <[email protected]> wrote:
>
> > I use svn:ignore on app/config/database.php, and only commit a generic
> > database.php.default file (that contains no usernames/passwords). Each
> > time I checkout the code (dev, staging,production) I rename
> > the .default file to database.php and make my edits on the server. So
> > ultimately no passwords are stored in version control. The downside to
> > this approach is that if you need to change the database.php.default
> > file (adding another db source, etc) you then need to manually add the
> > changes into each deployment area.
>
> > I'm sure there's a better way, but this works for me.
>
> > Cheers,
> > Adam
>
> > On Feb 11, 12:38 pm, travisbeck <[email protected]> wrote:
>
> > > i see that you can add multiple database defnitions for
> > > development,production, and test in the database.php file.
>
> > > how do you get your application to switch between the different
> > > environments?  Our app is in version control and i'd very much like to
> > > not have to constantly worry about the database config everytime a
> > > change gets commited.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to