joshi
joshi

Reputation: 355

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?

Upvotes: 4

Views: 5100

Answers (3)

gsd15s6d465
gsd15s6d465

Reputation: 1

Be aware that netbeans doenst work with $_SERVER['PATH_INFO'] and url like http://127.0.0.1/site/test.php/v1/v2/parametertoputonphpathinfo/v3, there is a bug of Mon Sep 09, 2013 8:54 am on netbeans board telling about it without response until now 2014:

http://forums.netbeans.org/topic56645.html

It make impossible debug frameworks using that sinatra way to routing requests.
Rewriting my simple Sinatra router to have a $_GET mode to debug and a better hook code.

Upvotes: 0

Scott Davey
Scott Davey

Reputation: 907

I found the same problem, and fixed it by upgrading my version of xdebug.

There appears to have been a bug in the version I was using (xdebug 2.1.3), but it all works fine on xdebug 2.2.3.

Use this tool for custom installation instructions for your environment. http://xdebug.org/wizard.php

Upvotes: 0

joshi
joshi

Reputation: 355

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.

Upvotes: 9

Related Questions