开发者

Moving between localhost and remote server with CodeIgniter

What's the best way to handle moving between development on localhost to live remote server? I have .htaccess mod_rewrite set, but that's not really a problem, because I haven't included that in my subversion repository so I'm not committing it as the rest of the site. But what about the config.php with the base_url? I need to have this set to localhost for development, but changed to the actual domain when deployed.

It's not a huge problem, but I will always have to remember to change this before each time I deploy, or remember to exclude it from deployment. 开发者_StackOverflowSo I was thinking maybe someone had a smart way to handle this?


You can load different configuration files depending on what you have set the ENVIRONMENT constant to in index.php. In your case you would create two copies of config.php. In your development copy you would have the base URL set to localhost and in the production copy you would have it set to example.com. Depending on what the ENVIRONMENT constant was set to, the appropriate configuration file would be loaded.

Look at Handling Multiple Environments and the "Environments" section in the Config Class documentation to see how to do this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜