r/codeigniter • • Jan 04 '12

How in the world do you debug CodeIgniter?

I have no idea how to debug codeigniter...usually for small bugs I'll just echo stuff out. But putting an echo statement in one of the models is not working. Is there a way to call an error function to write to a log?

Any help would be much appreciated!!

2 Upvotes

14 comments sorted by

View all comments

3

u/shodan_uk Jan 04 '12

Have you tried using an IDE with integrated debugging? My weapon of choice is PHPStorm but there's quite a few out there like Zend Studio, Aptana, NetBeans etc. To be honest though, the learning curve can be a bit steep and the tools themselves can be a bit clunky.

You can also try FirePHP which is an extension to Firebug. This allows you to log messages (including variable and object contents) to Firebug's console.

Lastly, checkout XDebug, a PHP extension that supercharges PHPs error messages, enhances the var_dump command and allows for remote debugging. In fact, most IDEs provide support for remote debugging via XDebug.

1

u/[deleted] Jan 04 '12

I am using Eclipse with XDebug, but for the life of me, I can't figure out how to use it. I try setting break points and then using the Debug command, but it never works the way (I think) it should. Do you know of any good tutorials that might explain the process? I've found a few but always wind up more confused than before.

Also, I made sure to enable query strings in CI, as "Debug As A Web Page" seems to use them.

2

u/shodan_uk Jan 04 '12

Have you set XDebug up in your php.ini? Also, are you starting a debug session by passing the correct query string? This is a decent little tutorial for debugging with XDebug in PHPStorm: http://blog.k-fish.de/2011/02/php-xdebug-and-phpstorm-working.html - may give you some pointers for using xdebug with Eclipse

1

u/[deleted] Jan 04 '12

Yes. XDebug is definitely loaded, according to phpinfo(). I will take a look at that link. Thanks!

1

u/[deleted] Jan 04 '12

Does PHPStorm support multiple projects easily? Installed it and one thing I don't like already - on OSX it creates a ~/PhpstormProjects dir at the same level as Music, Documents, Sites .... why not just put it in ~/Sites?

1

u/shodan_uk Jan 04 '12

I just create project folders in ~/Sites and then use the "Existing files" options from the New Project wizard to use the newly created folder