imanghafoori/laravel-fast-refresh-database 问题修复 & 功能扩展

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

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

imanghafoori/laravel-fast-refresh-database

最新稳定版本:v1.0.1

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

Star History Chart

统计信息

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

GitHub 信息

  • Stars: 14
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-09-11

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固