CodeIgniter Forums
Development mode for personal IP address - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Development mode for personal IP address (/showthread.php?tid=81730)



Development mode for personal IP address - 5flex - 04-19-2022

Hello everyone! Sorry for my bad English, but I try to write my question.
Tell me please, How I can set (or switch on) CI_ENVIRONMENT to DEVELOPMENT mode for my personal IP address?
As example... I have a working web project and I have a bug on any page and I want to switch on development mode, BUT! If I will change .env file and will set development mode this parameter will be set for all clients on my web site. How I can set something:

if($_SERVER['REMOTE_ADDR'] == '12.34.56.78') {
env(' CI_ENVIRONMENT', 'development')
}
I will believe would your understood my question. Thank's!


RE: Development mode for personal IP address - captain-sensible - 04-19-2022

the lateral thinking mode is this : you have your web set up on local host . thats where you play with it , fix bugs and improve it. on that one you have development mode. your live web is a clone of your dev web on local host, and in that case its set to production mode. Every improvement you do on localhost you push to live. No need then to change modeon live


RE: Development mode for personal IP address - 5flex - 04-19-2022

(04-19-2022, 08:54 AM)captain-sensible Wrote: the lateral thinking mode is this :  you have your web set up on local host . thats where you play with it , fix bugs and improve it. on that one you have development mode. your live  web is a clone of your    dev web on local host, and in that case its set to production mode. Every improvement you do on  localhost you push to live. No need then to  change modeon live
Thank's for your answer, but what you have said is quite obvious, but I am interested in the answer specifically to my question. Is it possible to implement this somehow within this framework or not? And if so, how?


RE: Development mode for personal IP address - InsiteFX - 04-20-2022

CodeIgniter 4 User Guide - The ENVIRONMENT Constant


RE: Development mode for personal IP address - datamweb - 04-20-2022

(04-19-2022, 04:21 AM)5flex Wrote: Hello everyone! Sorry for my bad English, but I try to write my question.
Tell me please, How I can set (or switch on) CI_ENVIRONMENT to DEVELOPMENT mode for my personal IP address?
As example... I have a working web project and I have a bug on any page and I want to switch on development mode, BUT! If I will change .env file and will set development mode this parameter will be set for all clients on my web site. How I can set something:

if($_SERVER['REMOTE_ADDR'] == '12.34.56.78') {
env(' CI_ENVIRONMENT', 'development')
}
I will believe would your understood my question. Thank's!

Hi, Just replace the following code in file app\Config\Boot\production.php.
Code:
<?php

    $yourStaticIP = '::1';
    if(\Config\Services::request()->getIPAddress() == $yourStaticIP){

        error_reporting(-1);
        ini_set('display_errors', '1');

        defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);

        defined('CI_DEBUG') || define('CI_DEBUG', true);
   
    }
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', false);

Note this:
1. Enter your IP in section
Code:
$yourStaticIP = '::1';
.
2. Your IP is dynamic so your IP changes when you turn off the modem. In this case, replace it again.

Enjoy!


RE: Development mode for personal IP address - 5flex - 04-20-2022

(04-20-2022, 02:02 AM)datamweb Wrote:
(04-19-2022, 04:21 AM)5flex Wrote: Hello everyone! Sorry for my bad English, but I try to write my question.
Tell me please, How I can set (or switch on) CI_ENVIRONMENT to DEVELOPMENT mode for my personal IP address?
As example... I have a working web project and I have a bug on any page and I want to switch on development mode, BUT! If I will change .env file and will set development mode this parameter will be set for all clients on my web site. How I can set something:

if($_SERVER['REMOTE_ADDR'] == '12.34.56.78') {
env(' CI_ENVIRONMENT', 'development')
}
I will believe would your understood my question. Thank's!

Hi, Just replace the following code in file app\Config\Boot\production.php.
Code:
<?php

    $yourStaticIP = '::1';
    if(\Config\Services::request()->getIPAddress() == $yourStaticIP){

        error_reporting(-1);
        ini_set('display_errors', '1');

        defined('SHOW_DEBUG_BACKTRACE') || define('SHOW_DEBUG_BACKTRACE', true);

        defined('CI_DEBUG') || define('CI_DEBUG', true);
   
    }
/*
|--------------------------------------------------------------------------
| ERROR DISPLAY
|--------------------------------------------------------------------------
| Don't show ANY in production environments. Instead, let the system catch
| it and display a generic error message.
*/
ini_set('display_errors', '0');
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);

/*
|--------------------------------------------------------------------------
| DEBUG MODE
|--------------------------------------------------------------------------
| Debug mode is an experimental flag that can allow changes throughout
| the system. It's not widely used currently, and may not survive
| release of the framework.
*/
defined('CI_DEBUG') || define('CI_DEBUG', false);

Note this:
1. Enter your IP in section
Code:
$yourStaticIP = '::1';
.
2. Your IP is dynamic so your IP changes when you turn off the modem. In this case, replace it again.

Enjoy!


Awesome!!!!! Very big thank you!!!!!