PHPackages                             mohamadtsn/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. mohamadtsn/laravel-fast-refresh-database

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

mohamadtsn/laravel-fast-refresh-database
========================================

Quickly refresh your large database in tests.

1.0.2(3w ago)03MITPHPPHP 8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*|8.5.\*

Since Oct 17Pushed 3w agoCompare

[ Source](https://github.com/mohamadtsn/laravel-fast-refresh-database)[ Packagist](https://packagist.org/packages/mohamadtsn/laravel-fast-refresh-database)[ Docs](https://github.com/mohamadtsn/laravel-fast-refresh-database)[ RSS](/packages/mohamadtsn-laravel-fast-refresh-database/feed)WikiDiscussions v1 Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (8)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 mohamadtsn/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 MohamadTsn\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/mohamadtsn)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

43

—

FairBetter than 89% of packages

Maintenance94

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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 ~63 days

Total

4

Last Release

27d ago

PHP version history (2 changes)1.0.0PHP 8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*

1.0.2PHP 8.0.\*|8.1.\*|8.2.\*|8.3.\*|8.4.\*|8.5.\*

### Community

Maintainers

![](https://www.gravatar.com/avatar/d4a03e6717c552d241d4af3be9f832ccd62796abb0eca9980f5b642923fa837c?d=identicon)[mohamad.borzoyi](/maintainers/mohamad.borzoyi)

---

Top Contributors

[![mohamadtsn](https://avatars.githubusercontent.com/u/61478011?v=4)](https://github.com/mohamadtsn "mohamadtsn (9 commits)")[![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)")

---

Tags

laravel-testing

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k41.3M38.3k](/packages/orchestra-testbench)[imanghafoori/laravel-microscope

Automatically test your laravel application

1.5k627.2k2](/packages/imanghafoori-laravel-microscope)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135212.4k7](/packages/statamic-rad-pack-runway)[guanguans/laravel-soar

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

2248.3k](/packages/guanguans-laravel-soar)[spurwork/spectator

Testing helpers for your OpenAPI spec

3041.5k](/packages/spurwork-spectator)[imanghafoori/laravel-makesure

A Laravel package to help you write expressive tests

212.8k3](/packages/imanghafoori-laravel-makesure)

PHPackages © 2026

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