Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 development mode returning extra HTML
#1

Hi to everyone,
I'm having an issue with Codeigniter 4 in development mode.
It is now the second case that, when I send data via Ajax, the code breaks in development mode since, aside from the JSON string I need, I also get some code from the debugger like the one below:

<script type="text/javascript"  id="debugbar_loader" data-time="1604332610" src="http://localhost/index.php?debugbar"></script><script type="text/javascript"  id="debugbar_dynamic_script"></script><style type="text/css"  id="debugbar_dynamic_style"></style>

To make sure everything runs smoothly I always need to switch back to production mode.
Anyone knows how to solve this problem? Thanks
Reply
#2

You could set the environment in your .htaccess then just remark out the one you do not want to use.

Code:
SetEnv CI_ENVIRONMENT development
#SetEnv CI_ENVIRONMENT production

I think I saw in the forum here a way of doing it in the index.php not sure where it is at.
What did you Try? What did you Get? What did you Expect?

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

I had a similar problem where the debugbar code was injected in my form data because I was editing an article containing html example.

It is already fixed in the develop branch. So I guess it will be included in the next release: https://github.com/codeigniter4/CodeIgniter4/pull/3804
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#4

It is not necessary to switch to production environment. You can disable toolbar in development mode - just disable CI_DEBUG.

In "/app/Config/Boot/development.php" change
PHP Code:
defined('CI_DEBUG') || define('CI_DEBUG'true); 
to
PHP Code:
defined('CI_DEBUG') || define('CI_DEBUG'false); 
Reply
#5

You can also comment the toolbar in the Filters configuration file

PHP Code:
    /**
     * List of filter aliases that are always
     * applied before and after every request.
     *
     * @var array
     */
    
public $globals = [
        
'before' => [
            
// 'honeypot',
            // 'csrf',
        
],
        
'after'  => [
            
'toolbar',
            
// 'honeypot',
        
],
    ]; 


https://github.com/codeigniter4/CodeIgni...rs.php#L36
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#6

(11-03-2020, 06:46 AM)T.O.M. Wrote: It is not necessary to switch to production environment. You can disable toolbar in development mode - just disable CI_DEBUG.

In "/app/Config/Boot/development.php" change
PHP Code:
defined('CI_DEBUG') || define('CI_DEBUG'true); 
to
PHP Code:
defined('CI_DEBUG') || define('CI_DEBUG'false); 
Thanks for the tip. But by doing so will I still get whatever errors the development mode usually displays?
Reply
#7

(11-04-2020, 03:46 PM)includebeer Wrote: You can also comment the toolbar in the Filters configuration file

PHP Code:
    /**
     * List of filter aliases that are always
     * applied before and after every request.
     *
     * @var array
     */
    
public $globals = [
        
'before' => [
            
// 'honeypot',
            // 'csrf',
        
],
        
'after'  => [
            
'toolbar',
            
// 'honeypot',
        
],
    ]; 


https://github.com/codeigniter4/CodeIgni...rs.php#L36

Thanks for the tip. But by doing so will I still get whatever errors the development mode usually displays?
Reply




Theme © iAndrew 2016 - Forum software by © MyBB