PHP code example of guanguans / laravel-dump-sql

1. Go to this page and download the library: Download guanguans/laravel-dump-sql library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

guanguans / laravel-dump-sql example snippets


$app->register(\Guanguans\LaravelDumpSql\ServiceProvider::class);

$sql = User::query()->where('id', 1)->toRawSql();
dd($sql);

User::query()->where('id', 1)->dumpSql();
User::query()->where('id', 2)->dumpSql();

User::query()->where('id', 1)->ddSql();
User::query()->where('id', 2)->ddSql();

User::query()->where('id', 1)->logListenedSql()->first();
User::query()->where('id', 2)->first();

User::query()->where('id', 1)->dumpListenedSql()->first();
User::query()->where('id', 2)->first();

User::query()->where('id', 1)->ddListenedSql()->first();
User::query()->where('id', 2)->first();
shell
$ php artisan server:dump-sql