承接 lane4core/dbschema 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

lane4core/dbschema

最新稳定版本:1.0.0

Composer 安装命令:

composer require lane4core/dbschema

包简介

A flexible package for analyzing and managing database schemas (PDO-based) with support for MySQL/MariaDB, PostgreSQL, and SQLite

README 文档

README

A flexible package for analyzing and managing database schemas (PDO-based) with support for MySQL/MariaDB, PostgreSQL, and SQLite.

Overview

This package provides a unified API to consistently retrieve schema information from different database systems. It includes specific implementations for common database drivers (MySQL/MariaDB, PostgreSQL, SQLite).

Purpose:

  • Unified retrieval of schema information (tables, columns, indexes, foreign keys)
  • Standardization of data structures across different database systems
  • Ability to extend behavior with custom repository implementations
  • High testability and interchangeability

Supported Database Types

The package includes schema repository implementations for the following database types:

  • MySQL / MariaDBMySql
  • PostgreSQLPostgres
  • SQLiteSqLite

Each repository class handles database-specific schema queries and returns results in consistent structures.

Installation

Using Composer:

composer require lane4core/dbschema

For local development:

git clone https://github.com/Lane4core/DbSchema.git
cd DbSchema
composer install

Configuration

DbSchema works with an existing PDO connection.

use PDO;

$pdo = new PDO('mysql:host=localhost;dbname=test', 'user', 'password');

Examples

Basic Usage

use Lane4core\DbSchema\DbSchema;

// Create PDO connection
$pdo = /* your PDO instance */;

$schema = new DbSchema($pdo);

// Retrieve all tables
$tables = $schema->tables();
print_r($tables);

// Retrieve columns of a table
$columns = $schema->columns('users');
print_r($columns);

// Retrieve specific columns
$specificColumns = $schema->columns('users', ['id', 'name', 'email']);
print_r($specificColumns);

// Retrieve indexes of a table
$indexes = $schema->indexes('users');
print_r($indexes);

// Retrieve foreign keys of a table
$foreignKeys = $schema->foreignKeys('orders');
print_r($foreignKeys);

// Get PHP type mapping for a DB type
$phpType = $schema->fieldType('VARCHAR');
echo $phpType; // "string"

Tests

The project includes PHPUnit tests located under tests/.

make phpunit

CI & Code Quality

The repository uses or recommends the following tools:

  • PHPStan for static analysis (Level 8)
  • PHPCS for code style checks
  • PHPUnit for unit tests (coverage 100%)
  • GitHub Actions for CI/CD

Typical CI steps:

  1. composer install
  2. make phpcs
  3. make phpstan
  4. make phpunit-coverage

License

This project is licensed under the MIT License – see LICENSE in the repository.

Enjoy and succeed with DbSchema!

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-10-19