多个环境与codeigniter [英] multiple environments with codeigniter

查看:93
本文介绍了多个环境与codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用多个环境,例如开发,测试,使用codeigniter为我的应用程序生产的最佳行动方案。



现在我有一个文件夹为我的应用程序。我看到的地方,在配置文件中为每个环境做一个文件夹,并放置例如每个环境文件夹中的数据库文件的副本。



这是处理多种环境的最佳方法吗?我问的原因是,如果我在我的开发子域,我仍然必须重新上传到主根文件夹所有相同的文件。这是最好的工作流吗?



所以基本上我有两个网站。



dev.siteurl.com
siteurl.com



我想找出最好的处理方法。因为我想知道我是否只需要重新上传所有的文件到主级别,以便它可以处理生产服务器或有一个更简单的方法。

>解决方案

是的,它的工作方式是在/ application / config文件夹下创建一个额外的嵌套文件夹称为开发,以便你有



/ application / config / development /



内部开发中,您将放置一个database.php文件的副本并更改开发数据库设置

/application/config/development/database.php



你必须告诉codeigniter你在哪个版本,根文件夹编辑index.php:



/index.php

  define('ENVIRONMENT','development'); 

当您想使用/config/development/database.php时, ,当你想使用生产数据库时,你将环境改为生产



编辑:CI TOC还有一个简短的部分解释这一点:http://ellislab.com/codeigniter/user-guide/general/environments.html


I'm trying to understand the best course of action with using multiple environments, such as development, testing, production for my application with codeigniter.

As of right now I have one folder for my application. I'm seen places that talk about in the config file doing a folder for each of the environments and placing for example a copy of the database file in each of the environment folders.

Is this the best method of handling multiple environments? The reason I'm asking is because if I work on my dev subdomain I'd still have to reupload to the main root folder all the same files. Is this the best workflow?

So basically I have two sites.

dev.siteurl.com siteurl.com

I'm trying to figure out the best option of handling this. Because I'm wondering if I'm going to just have to reupload all the files again to the main level so that it can handle the production server or is there an easier way.

解决方案

Yes the way it works is under your /application/config folder you create an extra nested folder called development so that you have

/application/config/development/

Inside development you will place a copy of your database.php file and change your development database settings

/application/config/development/database.php

THEN you have to tell codeigniter which version you are on, so in your base root folder edit index.php:

/index.php

define('ENVIRONMENT', 'development');

When you want to use the /config/development/database.php you will change your environment to development, and when you want to use the production database you will change the environment to production

edit: also the CI TOC has a brief section explaining this: http://ellislab.com/codeigniter/user-guide/general/environments.html

这篇关于多个环境与codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆