xpyct / sql-viewer
SQL Viewer for Laravel
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 0
Open Issues: 0
Language:TypeScript
Requires
- php: ^8.1
- doctrine/dbal: ^4.2
- greenlion/php-sql-parser: ^4.6
- illuminate/support: ^8.0|^9.0|^10.0|^11.0
This package is auto-updated.
Last update: 2025-04-04 00:10:07 UTC
README
SQL Viewer for Laravel
Requirements | Installation | Usage
Documentation
Documentation can be found on the official website.
Get Started
Requirements
- PHP 8.0+
- Laravel 8+
Installation
To install the package via composer, Run:
composer require xpyct/sql-viewer
After installing the package, publish the front-end assets by running:
php artisan sql-viewer:install
This is the content that will be published to config/sql-viewer.php
return [ /* * By default this package will only run in local development. * Do not change this, unless you know what your are doing. */ 'enabled' => env('SQL_VIEWER_ENABLED', env('APP_ENV') === 'local'), /* * The SqlViewer page will be available on this path. */ 'path' => env('SQL_VIEWER_PATH', 'sql-viewer'), /* * These middleware will be assigned to every SqlViewer route, giving you the chance * to add your own middlewares to this list or change any of the existing middleware. */ 'middleware' => [ 'web', // Uncomment this if you want to add auth middleware // 'auth', ], /* * Forbidden actions in SQL queries */ 'forbidden_actions' => [ 'DROP', 'TRUNCATE', 'DELETE', 'CREATE', ], /* * Maximum number of rows that can be returned from a query (add it to the LIMIT clause) */ 'max_limit' => 100, ];
Usage
Once the installation is complete, you will be able to access SQL Viewer directly in your browser.
By default, the application is available at: {APP_URL}/sql-viewer
.
Authorization
To authorize, add your email to the sql-viewer config and set enabled variable.
You can register a viewSqlViewer gate with your own logic. A good place to do this is in the AuthServiceProvider that ships with Laravel.
public function boot() { Gate::define('viewSqlViewer', function ($user = null) { return true; }); }
Credits
License
The MIT License (MIT).