php-db/phpdb
Composer 安装命令:
composer require php-db/phpdb
包简介
Database abstraction layer, SQL abstraction, result set abstraction, and RowDataGateway and TableDataGateway implementations
README 文档
README
The continuation of the Laminas Db component, now under the php-db organization.
The following information is outdated and will be updated in the coming days.
PhpDb is a component that abstract the access to a Database using an object
oriented API to build the queries. PhpDb consumes different storage adapters
to access different database vendors such as MySQL, PostgreSQL, Oracle, IBM DB2,
Microsoft Sql Server, PDO, etc.
Contributing
Please be sure to read the contributor's guide for general information on contributing. This section outlines specifics for php-db.
Test suites
The phpunit.xml.dist file defines two test suites, "unit test" and "integration test".
You can run one or the other using the --testsuite option to phpunit:
./vendor/bin/phpunit --testsuite "unit test" # unit tests only ./vendor/bin/phpunit --testsuite "integration test" # integration tests only
Unit tests do not require additional functionality beyond having the appropriate database extensions present and loaded in your PHP binary.
Integration tests
To run the integration tests, you need databases. So, the repository includes a Docker Compose configuration which allows you to start a test environment that provides several of our target databases, including MySQL and PostgreSQL, and SQLite.
To start up the configuration, run the following command:
docker compose up -d
To test that the environment is up and running, run the following command:
docker compose ps
You should see output similar to the following:
docker compose ps NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS laminas-db-mysql-1 docker.io/library/laminas-db-mysql:latest "mysqld" mysql 7 hours ago Up 7 hours laminas-db-php-1 docker.io/library/laminas-db-php:latest "apache2-foreground" php 7 hours ago Up 7 hours laminas-db-postgresql-1 docker.io/library/laminas-db-postgresql:latest "postgres" postgresql 7 hours ago Up 7 hours
If you see three containers listed, then they're all running, and you are ready to run the test suite.
So, copy phpunit.xml.dist to phpunit.xml, and change the following environment variable to "true" to enable the three databases:
- TESTS_PHPDB_ADAPTER_DRIVER_MYSQL
- TESTS_PHPDB_ADAPTER_DRIVER_PGSQL
- TESTS_PHPDB_ADAPTER_DRIVER_SQLITE_MEMORY
From there, you can run the integration tests by running the following command:
docker compose exec php composer test-integration
Tip
If you want to grow your Docker Compose knowledge, grab a (free) copy of Deploy with Docker Compose.
- File issues at https://github.com/php-db/phpdb/issues
- Documentation is at https://docs.php-db.dev
php-db/phpdb 适用场景与选型建议
php-db/phpdb 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 57.3k 次下载、GitHub Stars 达 19, 最近一次更新时间为 2025 年 07 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「db」 「laminas」 「php-db」 「mezzio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 php-db/phpdb 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 php-db/phpdb 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 php-db/phpdb 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This package provide a Geo modules for yawik.
PSR-11 Aura.DI container configurator for Laminas and Mezzio applications. Drop-in replacement for the archived laminas/laminas-auradi-config with PHP 8.4 and 8.5 support.
MySQL support for php-db
MongoDB Adapter to be used with Laminas Paginator
Laminas API Tools Client API Service Consumer
Utils to load, parse and work with configuration on Mezzio projects
统计信息
- 总下载量: 57.3k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 19
- 点击次数: 28
- 依赖项目数: 8
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2025-07-07