PHPackages                             stateforge/scenario-laravel - 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. stateforge/scenario-laravel

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

stateforge/scenario-laravel
===========================

Laravel adapter for Stateforge Scenario Core – declarative, attribute-driven scenario execution for reproducible application state.

1.1.1(1mo ago)02BSD-3-ClausePHPPHP &gt;=8.2CI passing

Since Apr 6Pushed 1w agoCompare

[ Source](https://github.com/laloona/scenario-laravel)[ Packagist](https://packagist.org/packages/stateforge/scenario-laravel)[ Docs](https://github.com/laloona/scenario-laravel)[ RSS](/packages/stateforge-scenario-laravel/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (8)Versions (9)Used By (0)

[![Stateforge\Scenario\Laravel](docs/scenario.png)](docs/scenario.png)

[![CI](https://github.com/laloona/scenario-laravel/actions/workflows/ci.yml/badge.svg)](https://github.com/laloona/scenario-laravel/actions/workflows/ci.yml/badge.svg)[![PHPStan](https://camo.githubusercontent.com/022b70e6631d055205dfebf2aa7e53b3f63e7a3ea04a18e86429f279e29a29f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e)](https://camo.githubusercontent.com/022b70e6631d055205dfebf2aa7e53b3f63e7a3ea04a18e86429f279e29a29f1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e)[![Stability](https://camo.githubusercontent.com/ab8ef3fe8abaa0d51cd12f22a8a8159f8022515a030b700ab4a35367d281028f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d737461626c652d627269676874677265656e)](https://camo.githubusercontent.com/ab8ef3fe8abaa0d51cd12f22a8a8159f8022515a030b700ab4a35367d281028f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73746162696c6974792d737461626c652d627269676874677265656e)[![Latest Version](https://camo.githubusercontent.com/9693c7fa1ec7032a0b71188645c32128207f6f3d5c9c164d5afd3d5164af4581/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374617465666f7267652f7363656e6172696f2d6c61726176656c)](https://camo.githubusercontent.com/9693c7fa1ec7032a0b71188645c32128207f6f3d5c9c164d5afd3d5164af4581/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7374617465666f7267652f7363656e6172696f2d6c61726176656c)[![PHP Version](https://camo.githubusercontent.com/ec9ea87774d0c7bd58a7e25db02641741913a923ab92acc24111cb9aadd42b5a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7374617465666f7267652f7363656e6172696f2d6c61726176656c)](https://camo.githubusercontent.com/ec9ea87774d0c7bd58a7e25db02641741913a923ab92acc24111cb9aadd42b5a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7374617465666f7267652f7363656e6172696f2d6c61726176656c)[![License](https://camo.githubusercontent.com/19a50bed38f3319c50f51417adee16658ca7c2a47d0d80c4fbb007d09fa5bf19/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c616c6f6f6e612f7363656e6172696f2d6c61726176656c)](https://camo.githubusercontent.com/19a50bed38f3319c50f51417adee16658ca7c2a47d0d80c4fbb007d09fa5bf19/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6c616c6f6f6e612f7363656e6172696f2d6c61726176656c)

---

Scenario Laravel
================

[](#scenario-laravel)

Laravel integration for Stateforge Scenario Core.

This package provides framework-specific integration for Laravel applications, enabling seamless scenario execution within PHPUnit tests and Artisan workflows.

It builds on top of `stateforge/scenario-core` and integrates with the Laravel container, Artisan console, and testing environment.

Requirements
------------

[](#requirements)

Scenario Laravel requires the following:

- PHP &gt;= 8.2
- Laravel 12+
- [stateforge/scenario-core](https://github.com/laloona/scenario-core)

Installation
------------

[](#installation)

> This package is intended for local, develop and testing use only.

```
composer require --dev stateforge/scenario-laravel
```

After installation, run the setup command:

```
php artisan scenario:install
```

The installation command generates the required configuration files:

- creates `scenario/bootstrap.php` for runtime bootstrapping
- generates `scenario.dist.xml` for configuration
- places the extension into `phpunit.xml` or `phpunit.dist.xml`

What This Package Provides
--------------------------

[](#what-this-package-provides)

Scenario Laravel integrates Scenario Core with:

- Laravel’s service container
- Laravel Artisan console
- Laravel application lifecycle
- PHPUnit integration

Service Provider
----------------

[](#service-provider)

The package automatically registers its service provider.

It handles:

- registering console commands
- wiring scenario services
- integrating the Scenario runtime with Laravel

Database Reset
--------------

[](#database-reset)

When using `#[RefreshDatabase]`, the Laravel integration resets the database using Laravel’s migration system.

The default behavior:

- runs `migrate:fresh`
- optionally supports connection-specific resets

Applying Scenarios in Unit Tests
--------------------------------

[](#applying-scenarios-in-unit-tests)

Scenarios can be applied declaratively using the `#[ApplyScenario]` attribute:

```
use Stateforge\Scenario\Core\Attribute\ApplyScenario;

#[ApplyScenario('my-scenario')]
final class MyTest extends TestCase
{
    #[ApplyScenario('my-second-scenario')]
    public function testSomethingImportant(): void
    {
        // scenario has already been applied, data can be tested
    }
}
```

Console Commands
----------------

[](#console-commands)

Scenario Laravel registers dedicated Artisan commands within your application.

You can discover them using:

```
php artisan list scenario
```

Available commands include:

- `scenario:list` – List available scenarios
- `scenario:apply` – Apply a scenario manually
- `scenario:debug` – Debug scenarios or unit tests
- `scenario:make` – Generate a new scenario
- `scenario:install` – Install Scenario into the project

Environment Restrictions
------------------------

[](#environment-restrictions)

Scenario commands are intended for local, development and testing environments only.

By default, they are restricted to:

- `local`
- `develop`
- `testing`

This can be configured via:

```
config('scenario.allowed_envs');
```

Next Steps
----------

[](#next-steps)

- [Getting Started](docs/getting-started.md)
- [Configuration](docs/configuration.md)
- [Scenarios](docs/scenarios.md)
- [Parameter Types](docs/parameter-types.md)
- [CLI Usage](docs/cli.md)
- [Testing with PHPUnit](docs/testing-with-phpunit.md)
- [Recipes](docs/recipes.md)

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance95

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Total

8

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/14c160ba8dd9d6012afbd54bd9cbd59c72cfc963a68c820589c8c01fa9c5c7ea?d=identicon)[laloona](/maintainers/laloona)

---

Top Contributors

[![laloona](https://avatars.githubusercontent.com/u/5313072?v=4)](https://github.com/laloona "laloona (58 commits)")

---

Tags

testingphpunitlaravelfixturesstatescenariotest data

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/stateforge-scenario-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/stateforge-scenario-laravel/health.svg)](https://phpackages.com/packages/stateforge-scenario-laravel)
```

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k42.5M41.0k](/packages/orchestra-testbench)[brianium/paratest

Parallel testing for PHP

2.5k136.1M984](/packages/brianium-paratest)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8320.3M75](/packages/orchestra-workbench)[hotmeteor/spectator

Testing helpers for your OpenAPI spec

3051.6M1](/packages/hotmeteor-spectator)[codewithdennis/larament

Larament is a time-saving starter kit to quickly launch Laravel 13.x projects. It includes FilamentPHP 5.x pre-installed and configured, along with additional tools and features to streamline your development workflow.

3991.8k](/packages/codewithdennis-larament)[guanguans/laravel-soar

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

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

PHPackages © 2026

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