Welcome Guest, Not a member yet? Register   Sign In
Development mode for personal IP address
#1

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!
Reply
#2

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
CMS CI4     I use Arch Linux by the way 

Reply
#3

(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?
Reply
#4

CodeIgniter 4 User Guide - The ENVIRONMENT Constant
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5
Heart 

(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!
Reply
#6

(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!!!!!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB