Search by

clearsoft / easysql-common

joao-jlcm

Shared code for the EasySQL PHP SDK packages (SQL safety validation, credential sanitization).

v3.3.0 2026-10-11 04:04 UTC

This package is auto-updated.

Last update: 2026-10-11 04:24:49 UTC


README

Shared code for the EasySQL PHP SDK packages.

Installation

composer require clearsoft/easysql-common

Requirements: PHP >= 8.2.

Contents

  • Clearsoft\EasySQL\Common\SqlValidator — client-side SELECT-only safety check used by the MySQL, PostgreSQL, SQLite and ClickHouse connectors before executing any generated SQL. Mirrors the server-side validator as defense in depth.
  • Clearsoft\EasySQL\Common\CredentialSanitizer — strips credentials (connection URIs and password=/pwd= assignments) from driver messages before they are surfaced or logged.

Usage

use Clearsoft\EasySQL\Common\SqlValidator;
use Clearsoft\EasySQL\Common\CredentialSanitizer;

$result = SqlValidator::validateSelectOnly('SELECT * FROM users LIMIT 10');
if (!$result['ok']) {
    throw new RuntimeException($result['reason']);
}

echo CredentialSanitizer::sanitize('postgres://user:secret@host:5432/db');
// postgres://***@host:5432/db

Tests

./vendor/bin/phpunit --testsuite common