PHPackages                             imanghafoori/laravel-fast-refresh-database - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. imanghafoori/laravel-fast-refresh-database

ActiveLibrary[Testing &amp; Quality](/categories/testing)

imanghafoori/laravel-fast-refresh-database
==========================================

Quickly refresh your large database in tests.

v1.0.1(6mo ago)145252MITPHPPHP 8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*

Since Sep 11Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/imanghafoori1/laravel-fast-refresh-database)[ Packagist](https://packagist.org/packages/imanghafoori/laravel-fast-refresh-database)[ Docs](https://github.com/imanghafoori1/laravel-fast-refresh-database)[ RSS](/packages/imanghafoori-laravel-fast-refresh-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

When to use:
------------

[](#when-to-use)

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:
--------

[](#install)

```
composer require imanghafoori/laravel-fast-refresh-database --dev
```

### How to Use:

[](#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):

[](#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
-------

[](#credits)

- [Iman](https://github.com/imanghafoori1)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

### 🙋 Contributing

[](#raising_hand-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

[](#exclamation-security)

If you discover any security-related issues, please email `imanghafoori1@gmail.com` instead of using the issue tracker.

❤️ Contributors
---------------

[](#️-contributors)

This project exists thanks to all the people who contribute. \[[Contributors](https://github.com/imanghafoori1/laravel-fast-refresh-database/graphs/contributors)\]. [![](https://camo.githubusercontent.com/f9fb8eb0b4bb83124e06362df51755f42b9e26db4aab3608498331624ad5f64d/68747470733a2f2f6f70656e636f6c6c6563746976652e636f6d2f6c61726176656c2d666173742d726566726573682d64617461626173652f636f6e7472696275746f72732e7376673f77696474683d38393026627574746f6e3d66616c7365)](https://github.com/imanghafoori1/laravel-fast-refresh-database/graphs/contributors)

⭐ Star History
--------------

[](#-star-history)

[![Star History Chart](https://camo.githubusercontent.com/3ffd06690e05099a541f28ec18d51ac07106d632abe94aa076f5a78ede6b76fe/68747470733a2f2f6170692e737461722d686973746f72792e636f6d2f7376673f7265706f733d696d616e676861666f6f7269312f6c61726176656c2d666173742d726566726573682d646174616261736526747970653d44617465)](https://star-history.com/#imanghafoori1/laravel-fast-refresh-database&Date)

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance67

Regular maintenance activity

Popularity24

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~37 days

Total

2

Last Release

205d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6961695?v=4)[Iman](/maintainers/imanghafoori1)[@imanghafoori1](https://github.com/imanghafoori1)

---

Top Contributors

[![imanghafoori1](https://avatars.githubusercontent.com/u/6961695?v=4)](https://github.com/imanghafoori1 "imanghafoori1 (7 commits)")[![hamidroohani](https://avatars.githubusercontent.com/u/44055990?v=4)](https://github.com/hamidroohani "hamidroohani (4 commits)")[![mohamadtsn](https://avatars.githubusercontent.com/u/61478011?v=4)](https://github.com/mohamadtsn "mohamadtsn (4 commits)")

---

Tags

laravel-testing

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/imanghafoori-laravel-fast-refresh-database/health.svg)

```
[![Health](https://phpackages.com/badges/imanghafoori-laravel-fast-refresh-database/health.svg)](https://phpackages.com/packages/imanghafoori-laravel-fast-refresh-database)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[imanghafoori/laravel-microscope

Automatically test your laravel application

1.5k613.7k2](/packages/imanghafoori-laravel-microscope)[hotmeteor/spectator

Testing helpers for your OpenAPI spec

3021.4M1](/packages/hotmeteor-spectator)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8017.0M43](/packages/orchestra-workbench)[botble/git-commit-checker

Check coding standard &amp; code syntax with Git pre-commit hook.

47186.4k1](/packages/botble-git-commit-checker)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
