Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
763 views
in Technique[技术] by (71.8m points)

multiple environments with codeigniter

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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: https://www.codeigniter.com/user_guide/general/environments.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...