Download the PHP package tokkerbaz/phpsql-lint without Composer

On this page you can find all versions of the php package tokkerbaz/phpsql-lint. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpsql-lint

phpsql-lint

A rule-based SQL linter, EXPLAIN-aware analyzer, and query log collector for PHP.

CI

What this is

What this is not

This is not a query optimizer. It does not have a cost model, does not know your table statistics or index cardinality, and does not rewrite your schema. Real query planners (MySQL's, Postgres's) already do that, with far more information than a static tool ever will. What this package does is surface known anti-patterns and real EXPLAIN output so a human can make an informed decision. Every suggested fix is a suggestion — nothing here mutates your schema or your queries automatically.

Install

Quick start — static linting

EXPLAIN-aware analysis

N+1 detection from a live request

Laravel integration (optional, zero-config)

If Laravel is present, package auto-discovery registers PhpSqlLintServiceProvider automatically — you don't need to touch config/app.php. The Laravel-specific code lives entirely under PhpSqlLint\Laravel\* and is never loaded for plain PHP projects; the core package (Analyzer, Rules, Collector, Debugger) has no dependency on Illuminate at all.

Then in .env:

That's it. With enabled=true and APP_ENV in the configured environments list (local by default — see config/phpsql-lint.php), the provider:

  1. Hooks DB::listen() to record every query Laravel runs (this is the idiomatic Laravel integration point — TrackedPdo below is for plain PHP, since Laravel manages its own PDO connections internally).
  2. Pushes RenderDebugPanel middleware onto the web group, which appends the floating debug panel to any HTML response.

Set render_panel to false in the published config if you'd rather query PageDebugger yourself (e.g. to log findings to your APM instead of rendering the HTML panel):

Note on test coverage: the Laravel provider and middleware are exercised manually but don't yet have an automated test suite (that would mean pulling in Orchestra Testbench) — worth flagging honestly rather than implying full coverage. The framework-agnostic core (rules, analyzer, collector, debugger) does have full unit test coverage; see tests/.

Always gate this to non-production environments — the panel and the DB::listen hook expose raw SQL and bindings, which you don't want on production traffic regardless of the enabled flag's default.

Debugging a whole page/request (plain PHP)

TrackedPdo is a drop-in PDO subclass that records every query automatically — no manual ->record() calls. PageDebugger then runs the static rule set and N+1 detection against everything that ran, and can render a floating HTML debug panel, similar in spirit to Symfony's profiler toolbar or Laravel Debugbar, but scoped to what this package checks (findings, N+1, timings).

The panel shows, per page load: total query count and time, every static-rule finding, any N+1 groups it caught, and the full query list with per-query timing and call site. It's entirely self-contained (inline CSS/JS, no CDN dependency) so it works even if the page's own asset pipeline is broken.

PageDebugger also exposes the underlying data if you'd rather build your own UI or feed it into logging/APM instead of the HTML panel:

Built-in rules

Rule id Severity Detects
no-select-star warning SELECT * usage
no-unconditional-update-delete error UPDATE/DELETE with no WHERE
no-leading-wildcard-like warning LIKE '%term' (index-defeating)
no-unbounded-in-list warning IN (...) with 100+ literal values

Writing a custom rule

Every rule implements a small interface, so adding your own is straightforward:

Register it with $analyzer->addRule(new NoOrderByRandRule()).

Development

License

MIT — see LICENSE.


All versions of phpsql-lint with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-pdo Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tokkerbaz/phpsql-lint contains the following files

Loading the files please wait ...