PHPackages                             glaucojrcarvalho/sql-console - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. glaucojrcarvalho/sql-console

ActiveLibrary[Database &amp; ORM](/categories/database)

glaucojrcarvalho/sql-console
============================

Browser SQL console for Laravel with safe-guarded execution and multi-connection support.

v1.1.4(3mo ago)02MITPHPPHP ^8.2

Since Feb 6Pushed 3mo agoCompare

[ Source](https://github.com/glaucojrcarvalho/laravel-sql-console)[ Packagist](https://packagist.org/packages/glaucojrcarvalho/sql-console)[ Docs](https://github.com/glaucojrcarvalho/laravel-sql-console)[ RSS](/packages/glaucojrcarvalho-sql-console/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (4)Versions (6)Used By (0)

SQL Console for Laravel
=======================

[](#sql-console-for-laravel)

`glaucojrcarvalho/sql-console` is a browser SQL console package for Laravel with safety guardrails.

Features
--------

[](#features)

- Single SQL statement per execution
- JSON bindings support (`:named` placeholders)
- Multi-connection support (MySQL, Oracle, and others you configure)
- Read/write statement control
- Optional write confirmation checkbox
- Optional role restriction
- Standalone UI or embedded in your own app layout

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 10, 11 or 12

Installation
------------

[](#installation)

### Option 1: Packagist (recommended after publish)

[](#option-1-packagist-recommended-after-publish)

```
composer require glaucojrcarvalho/sql-console:^1.1
php artisan vendor:publish --tag=sql-console-config
```

### Option 2: Directly from GitHub

[](#option-2-directly-from-github)

```
composer config repositories.glaucojrcarvalho-sql-console vcs https://github.com/glaucojrcarvalho/laravel-sql-console.git
composer require glaucojrcarvalho/sql-console:^1.1
php artisan vendor:publish --tag=sql-console-config
```

### Option 3: Local path (development)

[](#option-3-local-path-development)

Add to your project `composer.json`:

```
{
  "repositories": [
    {
      "type": "path",
      "url": "../packages/sql-console",
      "options": { "symlink": true }
    }
  ],
  "require": {
    "glaucojrcarvalho/sql-console": "*"
  }
}
```

Then:

```
composer update glaucojrcarvalho/sql-console --ignore-platform-reqs
php artisan vendor:publish --tag=sql-console-config
```

Routes
------

[](#routes)

- `GET /admin/sql-console` (`admin.sql.console.index`)
- `POST /admin/sql-console/run` (`admin.sql.console.run`)

Configuration
-------------

[](#configuration)

Published file: `config/sql-console.php`

```
return [
    'route_prefix' => 'admin/sql-console',
    'middleware' => ['web', 'auth'],
    'layout' => null, // ex: 'template.main'
    'authorization_mode' => 'role', // role | allowlist | any_auth
    'manager_role_id' => env('SQL_CONSOLE_MANAGER_ROLE_ID'),
    'role_field' => 'role_id',
    'allowlist' => [
        'table' => 'sql_console_allowed_users',
        'user_identifier_field' => 'id',
        'user_identifier_column' => 'user_identifier',
        'active_column' => 'is_active',
        'can_write_column' => 'can_write',
    ],
    'connections' => [
        'mysql' => 'MySQL',
        'oracle' => 'Oracle',
    ],
    'max_rows' => 200,
    'require_write_confirmation' => true,
];
```

Notes:

- `authorization_mode=role` uses `manager_role_id`.
- `authorization_mode=allowlist` uses a DB table to decide who can access and write.
- `authorization_mode=any_auth` allows any authenticated user.
- Keep this route protected in production.

Optional Allowlist Table
------------------------

[](#optional-allowlist-table)

If you want per-user permissions (recommended for production/shared environments):

```
php artisan vendor:publish --tag=sql-console-migrations
php artisan migrate
```

Then insert allowed users in `sql_console_allowed_users`:

- `user_identifier`: matches your auth user field (default `users.id`)
- `is_active`: true/false
- `can_write`: true/false

Example:

```
INSERT INTO sql_console_allowed_users (user_identifier, is_active, can_write, created_at, updated_at)
VALUES ('1', 1, 0, NOW(), NOW());
```

### Manage Allowlist via Artisan (No Workbench)

[](#manage-allowlist-via-artisan-no-workbench)

Allow user (read-only):

```
php artisan sql-console:allow 1
```

Allow user with write permission:

```
php artisan sql-console:allow 1 --write
```

Revoke user (set inactive):

```
php artisan sql-console:revoke 1
```

Revoke user and delete row:

```
php artisan sql-console:revoke 1 --delete
```

Security Notes
--------------

[](#security-notes)

- This tool is intentionally restricted to one SQL statement at a time.
- DDL/admin keywords are blocked by default (`drop`, `truncate`, `alter`, etc.).
- Use least-privilege database credentials for any connection exposed here.
- Prefer `authorization_mode=allowlist` in production to explicitly control users and write access.

Release Flow
------------

[](#release-flow)

1. Push package to `main`
2. Create a semantic tag (example: `v1.0.0`)
3. Register/update repository on Packagist
4. For each new release, push a new tag (`v1.0.1`, `v1.1.0`, etc.)

Release Notes
-------------

[](#release-notes)

- Do not define `version` in `composer.json`.
- Package versions are controlled by Git tags (`v1.1.3`, `v1.1.4`, ...).
- After pushing a new tag, trigger update on Packagist.

Troubleshooting Packagist
-------------------------

[](#troubleshooting-packagist)

If Packagist shows:

`tag (...) does not match version (...) in composer.json`

it means old tags were created when a fixed `version` field existed in `composer.json`.

Fix:

1. Ensure `composer.json` has no `version` field.
2. Commit and push.
3. Create a new tag (do not reuse old tags).
4. Update the package on Packagist.

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance81

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

101d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d654c92da10d02a5ef25ab77a6e3c1be03f021e450384bf914e434007a24b11?d=identicon)[glaucojrcarvalho](/maintainers/glaucojrcarvalho)

---

Top Contributors

[![glaucojrcarvalho](https://avatars.githubusercontent.com/u/82765483?v=4)](https://github.com/glaucojrcarvalho "glaucojrcarvalho (7 commits)")

---

Tags

databaselaravelphpconsolelaraveldatabasemysqlsqloracle

### Embed Badge

![Health badge](/badges/glaucojrcarvalho-sql-console/health.svg)

```
[![Health](https://phpackages.com/badges/glaucojrcarvalho-sql-console/health.svg)](https://phpackages.com/packages/glaucojrcarvalho-sql-console)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[danielme85/laravel-log-to-db

Custom Laravel Log channel handler that can store log events to SQL or MongoDB databases. Uses Laravel native logging functionality.

135934.5k1](/packages/danielme85-laravel-log-to-db)[illuminated/db-profiler

Database Profiler for Laravel Web and Console Applications.

168237.4k](/packages/illuminated-db-profiler)[sarfraznawaz2005/indexer

Laravel package to monitor SELECT queries and offer best possible INDEX fields.

562.7k](/packages/sarfraznawaz2005-indexer)[guanguans/laravel-dump-sql

laravel 中轻松容易的输出完整的 SQL 语句。 - Easy output of complete SQL statements for laravel framework.

3635.6k](/packages/guanguans-laravel-dump-sql)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
