Welcome Guest, Not a member yet? Register   Sign In
Using XDebug with CodeIgniter
#4

[eluser]Neovive[/eluser]
mdale,

Welcome to CI. Debugging in PHP is always a weird thing -- I have never found it very useful and haven't used it since switching to CI -- it's very hard to follow the code, since CI (and all other PHP frameworks) go back and forth between core framework classes and your custom code. You have to set your breakpoints very carefully.

Regarding your questions, XAMPP and WAMP are essentially the same thing -- so I doubt that is the issue. I have never used XAMPP though. You can download WAMP at (http://www.wampserver.com/).

Here are a few other things to try:

1) Make sure the Debugger DLL's are installed properly by checking phpinfo().
2) Make sure to set a breakpoint in Eclipse prior to starting the debugger.
3) Make sure to use the "Step Into" button to run the code, so you can watch what happens.


Overall, I would recommend using the the built-in CodeIgniter Profiler, which outputs most of the information needed to successfully debug. Adding a few random print_r statements seems to handle the rest. To use the CI Profiler, just add $this->output->enable_profiler(TRUE); to your controller. If you want to include Session information in the profiler output (which I find very useful), do the following:

1) Create a file "My Profiler.php" in the "application/libraries" folder.
2) Insert the following code:

Code:
<?
class MY_Profiler extends CI_Profiler {

    function MY_Profiler()     {
        
        $CI =& get_instance();
        parent::CI_Profiler();
    }

    // --------------------------------------------------------------------

    /**
     * Compile $_POST Data
     *
     * @access    private
     * @return    string
     */    
    function _compile_session() {    
        $output  = "\n\n";
        $output .= '<fieldset style="border:1px solid #020;padding:6px 10px 10px 10px;margin:20px 0 20px 0;background-color:#eee">';
        $output .= "\n";
        $output .= '<legend style="color:#020;">SESSION DATA</legend>';
        $output .= "\n";
        
        if (count($this->CI->session->userdata) == 0) {
            $output .= "<div style='color:#009900;font-weight:normal;padding:4px 0 4px 0'>No Session data exists</div>";
        } else {
            $output .= "\n\n<table cellpadding='4' cellspacing='5' border='0' width='100%'>\n";
            
            foreach ($this->CI->session->userdata as $key => $val)  {
                                
                $output .= "<tr><td align='right' width='20%' style='color:#000;background-color:#ddd;padding:4px 10px;'>$key</td><td align='left' width='80%' style='color:#000;font-weight:normal;background-color:#ddd;padding:4px 10px;'>";
                if (is_array($val)) {
                        $output .= "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>";
                } else     {
                    $output .= htmlspecialchars(stripslashes($val));
                }
                
                $output .= "</td></tr>\n";
            }
        }
                    
        $output .= "</table>\n";        
    
        $output .= "</fieldset>";

        return $output;    
    }
    
    // --------------------------------------------------------------------
    
    /**
     * Run the Profiler
     *
     * @access    private
     * @return    string
     */    
    function run($output = '')
    {        
        $output = '<br clear="all" />';
        $output .= "<div style='background-color:#fff;padding:10px;'>";
        $output .= $this->_compile_benchmarks();
        $output .= $this->_compile_post();
        $output .= $this->_compile_session();
        $output .= $this->_compile_queries();
        
        $output .= '</div>';
        
        return $output;
    }    

}
?&gt;


Messages In This Thread
Using XDebug with CodeIgniter - by El Forum - 01-08-2008, 12:23 PM
Using XDebug with CodeIgniter - by El Forum - 01-08-2008, 02:06 PM
Using XDebug with CodeIgniter - by El Forum - 01-14-2008, 07:41 AM
Using XDebug with CodeIgniter - by El Forum - 01-14-2008, 09:19 AM
Using XDebug with CodeIgniter - by El Forum - 01-26-2009, 06:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB