Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeigniter + NetBeans + XDebug : Debugger not working after redirect()

I am working on a project that uses CodeIgniter. I use Netbeans as my IDE and I have Xdebug installed. I am using XAMPP for local development.

What Works: Xdebug is working fine for normal PHP code.

Problem: However, I am facing problems debugging my CodeIgniter project. Debugger stops on a redirect()

Problem Details: Start debugging project in netbeans. Debugger starts and we see homepage. On homepage, there is a link that corresponds to a method in homepage controller. Debugger reaches the method in controller to which the link points to. In this method there is a redirect. At the point of redirect debugger STOPS.

Relevant Code Snippet(s):

URL That is clicked (This is part of the header menu)

<a href="<?= base_url("somefunc/"); ?>">Click Me </a>

routes.php - Reroute for prettier url.

$route['somefunc'] = "foo/somefunc";

And in my Foo Controller (foo.php):

class Foo extends CI_Controller {
    public function somefunc()
    {
        redirect('/bar/otherfunc');  // DEBUGGER REACHES TILL HERE THEN STOPS WORKING
    }
}

As said above in the comment in function somefunc(), Xdebug stops working at the place where the redirect happens.

Additionally, the following information might be of some use:

config.php

$config['uri_protocol'] = 'AUTO'; // I have also tried PATH_INFO, QUERY_STRING, REQUEST_URI & ORIG_PATH_INFO.
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = TRUE; // Have tried FALSE too.
$config['index_page'] = ''; // Tried index.php too.

xdebug settings in php.ini

zend_extension ="path\to\xampp\php\ext\php_xdebug.dll"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000

NOTE - I have already tried playing around with different suggestions that I have seen here as well as through google but to no avail. Can somebody please point me in the right direction?

like image 694
joshi Avatar asked Jan 13 '23 03:01

joshi


1 Answers

Found a solution. Perhaps this might help someone else who has been struggling with this. Apparantly to allow smooth debugging, you need to include the option:

xdebug.remote_autostart=1

in your php.ini. These settings work for me now:

xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
xdebug.remote_autostart=1

The last line is the option I found on (Xdebug Official Documentation). The relevant part of the documentation is mentioned below:

xdebug.remote_autostart

Type: boolean, Default value: 0

Normally you need to use a specific HTTP GET/POST variable to start remote debugging (see Remote Debugging). When this setting is set to 1, Xdebug will always attempt to start a remote debugging session and try to connect to a client, even if the GET/POST/COOKIE variable was not present.

like image 118
joshi Avatar answered Jan 26 '23 07:01

joshi