PHP code example of dbmind / laravel-sql

1. Go to this page and download the library: Download dbmind/laravel-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/ */

    

dbmind / laravel-sql example snippets


use DBMind1\Laravel\Facades\DBMind1;
use DBMind1\Domain\DTO\AskRequest;

$response = DBMind1::ask(new AskRequest('top 3 customers by spend', allowClarify: false));

if ($response->isClarification()) {
    // $response->clarifyingQuestions() — collect answers, then:
    // DBMind1::ask($request->withClarification($q, $a));
}

$response->answer;            // the grounded answer
$response->metadata['sql'];   // the read-only SELECT that ran
bash
php artisan dbmind1:install      # 1) cloud API key or local Ollama  2) exclude tables  → done
php artisan dbmind1:doctor       # health: DB read access + the AI gateway
php artisan dbmind1:discover     # read-only: list connections, tables, columns
php artisan dbmind1:sync         # after migrations: auto-approve new tables, refresh metadata
php artisan dbmind1:test "which users spent the most? top 3 spenders" --show-sql