(PHP) Get a list of run database queries in Laravel

By | July 5, 2015

This is great if you want to see what queries are actually run when using Eloquent.

        // Get all querys run
        $queries = DB::getQueryLog(); 

        // If you want to sort them by time this works
        usort($queries, function ($a, $b) {
            return $a['time'] < $b['time'];

        // Print them on screen in a readable way
        echo '<pre>';
        echo '</pre>';

Leave a Reply

Your email address will not be published. Required fields are marked *