debugging codeigniter controller

how can i debug a controller in codeigniter?
when i set a breakpoint in a controller class action method it never breaks.
if i set it in the view, it will break

To start debugging I click on the listen button in phpstorm, then click start debugging and start profiling in the browser.
I also set up a configuration of type 'php web application'

thank you,

Comment actions Permalink

Hi there,

If it works for you in view files then it should also work in controller -- there is no fundamental difference between them for PHP debugger.

Can you double check what lines do you put your breakpoints in? Xdebug have weird problems with triggering breakpoints at certain lines (e.g. multiline statement; loop with no braces around instruction etc).

The brekpoint icon in PhpStorm -- how does it look after starting debug session: plain red circle .. or red circle with check/tick icon inside ?

Do you use symbolic links maybe (where controller files are)? If so -- you will have to setup correct path mappings as xdebug works with real/resolved paths only.

Comment actions Permalink

thanks for the reply,
i included a little code below as an example.
i just noticed that breakpoints in the __construct of the base controller class works.  for example i can break on $this->data['title'].
i cant break in the front controller's __construct methods or in the front controllers action methods (index() for example.)
the breakpoints are solid red unless it breaks in the base controller's construct method.  then its red with a red check mark inside.  if i click play ('resume program execution' button) when it breaks in the base controller, it doesnt break anywhere else, and the breakpoints turn solid red again.
no symbolic links were used either.

thanks again for your help.

class ApplicationBase extends CI_Controller{

    protected $data = array();

     * ensures users are logged in.
    function __construct(){
        if ( !isset($_SESSION['user']) ) {
        } else {
            $this->data['user'] = $_SESSION['user'];
            $this->data['title'] = 'My Site';                         // <-- Break point here works
            $this->data['body'] = 'Content goes Here';

class FrontController extends ApplicationBase {

    public function index()
        $this->load->library('Template');                              // <-- Break point here doesnt work
        $this->template->load('bootstrap','front', $this->data);

    function __construct(){
        $this->data['otherContent'] = 'other content';          // <-- Break point here doesnt work

Comment actions Permalink

Is there anyway to debug a view as well, that has both php and javascript code. I am able to debug the php parts of the code but not javascript


Please sign in to leave a comment.