title: How to debug eloquent queries executed in Codeigniter
body: <p>I'm using Eloquent 5.* on my CodeIgniter3.1.1 project, Everything works fine however i want to check the queries executed when a request is processed,</p>
  
  <p>After some googling i came accross <a href="http://jamieonsoftware.com/post/90299647695/using-eloquent-orm-inside-codeigniter-with-added" rel="nofollow noreferrer">Using Eloquent ORM inside CodeIgniter with added Query Logging</a> and having CI Profiler enabled i see "No Queries Executed",</p>
  
  <p>my <code>database.php</code> configuration for Eloquent looks as below</p>
  
  <pre><code>//Eloquent ORM database connection
  
  use Illuminate\Database\Capsule\Manager as Capsule;
  
  $capsule = new Capsule;
  $capsule-&gt;addConnection(array(
  'driver' =&gt; 'mysql',
   'dsn' =&gt; 'mysql:host=localhost; dbname=communit_iwa_test charset=utf8;',
  'host' =&gt; $db['default']['hostname'],
  'database' =&gt; $db['default']['database'],
  'username' =&gt; $db['default']['username'],
  'password' =&gt; $db['default']['password'],
  'charset' =&gt; 'utf8',
  'collation' =&gt; 'utf8_unicode_ci',
  'prefix' =&gt; $db['default']['dbprefix'],
  ));
  $capsule-&gt;setAsGlobal();  
  $capsule-&gt;bootEloquent();
  
  
  $events = new Illuminate\Events\Dispatcher;
  $events-&gt;listen('illuminate.query',function($query, $bindings, $time,$name) {
  
  // Format binding data for sql insertion
  
  foreach ($bindings as $i =&gt; $binding) {
      if ($binding instanceof \DateTime) {
          $bindings[$i] = $binding-&gt;format('\'Y-m-d H:i:s\'');
      } else if (is_string($binding)) {
          $bindings[$i] = "'$binding'";
      }
  }
  
  // Insert bindings into query
  $query = str_replace(array('%', '?'), array('%%', '%s'), $query);
  $query = vsprintf($query, $bindings);
  
  // Add it into CodeIgniter
  $db = &amp; get_instance()-&gt;db;
  $db-&gt;query_times[] = $time;
  $db-&gt;queries[] = $query;
  });
  
  $capsule-&gt;setEventDispatcher($events);
  /* End of file database.php */
  /* Location: ./application/config/database.php */
  </code></pre>
  
  <p>Your Help is appreciated in advance</p>