Debugging Codeigniter with XDebug using PHPStorm Debugging Codeigniter with XDebug using PHPStorm codeigniter codeigniter

Debugging Codeigniter with XDebug using PHPStorm


Thanks to LazyOne, who enlightened me in the comments I was able to find my mistakes and the solution.

The very first reason why a 404 page was shown when browsing the site with PhpStorm, was that I was using PhpStorm's built in web server and not my Apache. And said server doesn't handle mod_rewrite rules (which simplifies URLs) so for sites using CodeIgniter it won't work. And since the scripts aren't directly accesible it's not possible by simply clicking run in PhpStorm. So we have to initiate the debug request from the outside/web browser.

Now 2 things have to be done:

  • PhpStorm (or your prefered IDE) has to know that a debugging process is about to happen
    • Using PhpStorm you have to toggle the “Start Listening for PHP Debug Connections” button.
    • See more in their documentation
  • When browsing your site as you normally would (in my case localhost/01_codeigniter_tutorial/public_html/index.php/controller) you have to set a XDebug cookie since xdebug will not automatically start a debugging session when you open a script.
    • The easiest way is to install a Browser add on since you only have to click a button (I used The easiest XDebug for FF)
    • Read this for more information

After everything has been set up, you only need to refresh your page and the IDE should receive your debugging request.