stateforge/scenario-symfony

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

Maintainers

Package info

github.com/laloona/scenario-symfony

Type:symfony-bundle

pkg:composer/stateforge/scenario-symfony

Statistics

Installs: 12

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-04-06 17:25 UTC

This package is auto-updated.

Last update: 2026-04-06 17:29:04 UTC


README

Symfony integration for Stateforge Scenario Core.

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

It builds on top of stateforge/scenario-core and integrates with the Symfony runtime and Doctrine ORM.

Requirements

Scenario Symfony requires the following:

Installation

This package is intended for test and development use only.

composer require --dev stateforge/scenario-symfony

After installation, run the setup command:

php bin/console scenario:install

The installation command generates the required configuration files:

  • creates the scenario.yaml package configuration
  • enables the symfony console scenario commands
  • generates the scenario.dist.xmlfor configuration
  • places the extendsion into phpunit.dist.xml or phpunit.xml

What This Package Provides

Scenario Symfony integrates Scenario Core with:

  • Symfony’s service container
  • Doctrine ORM (for database reset handling)
  • Symfony Console
  • Symfony test kernel lifecycle

Enabling the Bundle

Register the bundle in your Symfony application:

// config/bundles.php

return [
    Stateforge\Scenario\Symfony\ScenarioSymfonyBundle::class => ['dev' => true, 'test' => true],
];

The bundle automatically:

  • registers attribute handlers
  • wires scenario services
  • configures database reset handling
  • integrates with PHPUnit extension

Database Reset (Doctrine Integration)

When using #[RefreshDatabase], the Symfony integration resets the database using Doctrine.

The default behavior:

  • recreate the database
  • executed all migrations

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

Scenario Symfony registers dedicated console commands within your Symfony application.

You can discover them using:

php bin/console list scenario

Next Steps