imanghafoori/laravel-fast-refresh-database
Composer 安装命令:
composer require imanghafoori/laravel-fast-refresh-database
包简介
Quickly refresh your large database in tests.
关键字:
README 文档
README
For large databases with more than 100 tables, it is very slow to drop all the tables and migrate again.
It is also still very slow to run the truncate query against all the tables.
The idea of this package is to truncate only the tables that are involved in that particular test and ignore the rest.
This way, only 5 to 6 tables need to be truncated after each test and not 200 tables.
Note that no table gets dropped or migrated. It only runs the truncate table_name query.
Install:
composer require imanghafoori/laravel-fast-refresh-database --dev
How to Use:
Add the trait to your test class. The package automatically starts watching insert queries before each test (via a PHPUnit @before hook) and truncates only the tables that were touched after each test:
use Imanghafoori\DatabaseFresh\FastRefreshDatabase; class MyTest extends TestCase { use FastRefreshDatabase; public function test_user_can_run() { // ... your test code } }
Tip: Put the trait on your base Tests\\TestCase to enable it for all tests.
Manual setup (legacy PHPUnit):
If your PHPUnit version does not support @before, you can still invoke the setup helper in setUp():
protected function setUp(): void { parent::setUp(); // Manually start watching inserts for this test process $this->setupDatabaseAndStartWatchingTables(); }
You may also check my other package as well:
Credits
License
The MIT License (MIT). Please see License File for more information.
🙋 Contributing
If you find an issue or have a better way to do something, feel free to open an issue or a pull request. If you use laravel-microscope in your open source project, create a pull request to provide its URL as a sample application in the README.md file.
❗ Security
If you discover any security-related issues, please email imanghafoori1@gmail.com instead of using the issue tracker.
❤️ Contributors
This project exists thanks to all the people who contribute. [Contributors].
⭐ Star History
imanghafoori/laravel-fast-refresh-database 适用场景与选型建议
imanghafoori/laravel-fast-refresh-database 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 553 次下载、GitHub Stars 达 14, 最近一次更新时间为 2025 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel-testing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 imanghafoori/laravel-fast-refresh-database 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 imanghafoori/laravel-fast-refresh-database 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 imanghafoori/laravel-fast-refresh-database 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Automatically test your laravel application
A laravel package which provides workflows and tooling around testing
A Laravel package to help you write expressive tests
Automatically test your laravel application
Quickly refresh your large database in tests.
统计信息
- 总下载量: 553
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 14
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-11