glaucojrcarvalho/sql-console 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

glaucojrcarvalho/sql-console

Composer 安装命令:

composer require glaucojrcarvalho/sql-console

包简介

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

README 文档

README

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

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

  • PHP 8.2+
  • Laravel 10, 11 or 12

Installation

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

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)

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

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

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

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)

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

  • 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

  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

  • 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

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.

glaucojrcarvalho/sql-console 适用场景与选型建议

glaucojrcarvalho/sql-console 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 02 月 06 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「database」 「sql」 「mysql」 「console」 「oracle」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 glaucojrcarvalho/sql-console 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 glaucojrcarvalho/sql-console 我们能提供哪些服务?
定制开发 / 二次开发

基于 glaucojrcarvalho/sql-console 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 30
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-06