• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change the ENVIRONMENT type

#1
When open the index.php file to change the ENVIRONMENT type I have found the following:

PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 

In the previous CI version was as the following:

PHP Code:
define('ENVIRONMENT''development'); 

And I could change the environment by replace "development" word to ("production" or "testing").

How can I do that in CI 3 ?
Reply

#2
For production:
PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production'); 

For testing:
PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'testing'); 

For development:
PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development'); 
Reply

#3
In the same way.
Reply

#4
If I can change it whether

PHP Code:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'testing');  // testing, production, development 

Or

PHP Code:
define('ENVIRONMENT''development');  // testing, production, development 

What is the benefit of the following condition

PHP Code:
isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'
Reply

#5
(03-31-2015, 06:52 AM)lionking Wrote: What is the benefit of the following condition

PHP Code:
isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'

I think, as a CodeIgniter user you do not have to care about it. Smile
Reply

#6
I have found the answer of my question.

http://bldn.se/post/codeigniter-introduc...rverci_env
http://www.patpohler.com/codeigniter-mul...vironments
Reply

#7
If you don't use the CI_ENV variable (which I'm guessing you're not), then there's no benefit from it. As I said - you can do it as previously just fine ... whether you remove the condition or not doesn't make a practical difference.
Reply

#8
Code:
if(! defined('ENVIRONMENT') )
{
    $domain = strtolower($_SERVER['HTTP_HOST']);
    switch($domain)
    {
        case 'www.yoursite.com' :
            define('ENVIRONMENT', 'production');
        break;
        case 'test.yoursite.com' :
            define('ENVIRONMENT', 'testing');
        break;
        default :
            define('ENVIRONMENT', 'development');
        break;
    }
}

I'm using the above code for my application. Hope it helps Idea
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.