Skip to content

Add Symfony 8 and Behat 4 support#219

Open
shahinataei-ts wants to merge 1 commit intoFriendsOfBehat:masterfrom
shahinataei-ts:symfony-8-behat-4-support
Open

Add Symfony 8 and Behat 4 support#219
shahinataei-ts wants to merge 1 commit intoFriendsOfBehat:masterfrom
shahinataei-ts:symfony-8-behat-4-support

Conversation

@shahinataei-ts
Copy link
Copy Markdown

Summary

This PR adds support for Symfony 8 and Behat 4.

The extension code already has the required return types on process() methods, making it compatible with both Behat 3.x and 4.x interfaces (as noted by @mpdude in #218).

Changes

  • Update behat/behat constraint to ^3.22 || ^4.0
  • Update symfony/* dependencies to include ^8.0
  • Add CI matrix entry for Symfony 8.0 with Behat 4.x-dev

Notes

  • Symfony 8 requires Behat 4.x-dev as Behat 3.x doesn't declare Symfony 8 compatibility
  • This PR builds on the discussion in Add Symfony 8 support #218, incorporating @mpdude's insight that the extension is already code-compatible

Related

The extension code already has the required return types on process() methods,
making it compatible with both Behat 3.x and 4.x interfaces.

Changes:
- Update behat/behat constraint to ^3.22 || ^4.0
- Update symfony/* dependencies to include ^8.0
- Add CI matrix entry for Symfony 8.0 with Behat 4.x-dev

Note: Symfony 8 requires Behat 4.x-dev as Behat 3.x doesn't declare
Symfony 8 compatibility in its composer.json constraints.

Relates to Behat/Behat#1687
@mpdude
Copy link
Copy Markdown
Contributor

mpdude commented Dec 22, 2025

Careful: There is no Behat 4 (yet), so you cannot truly know what the API might look like or how it might change. So maybe it's too early to declare compatibility.

@shahinataei-ts
Copy link
Copy Markdown
Author

shahinataei-ts commented Dec 23, 2025

Careful: There is no Behat 4 (yet), so you cannot truly know what the API might look like or how it might change. So maybe it's too early to declare compatibility.

Thanks @mpdude, fair point.

You're right that Behat 4 isn't released yet. However, we're blocked on Symfony 8 since Behat 3.x doesn't support it, and the extension only uses core Behat interfaces that are unlikely to change before release.

If you prefer a more conservative approach, I'm happy to:

  • Keep ^3.22 only and just add CI testing for 4.x-dev
  • Or use ^3.22 || 4.0.x-dev to be explicit about the dev constraint

What works best for this project?

@aso824
Copy link
Copy Markdown

aso824 commented Mar 1, 2026

You need also to add extension in configuration:

new Profile('default')
    ->withExtension(
        new class implements \Behat\Config\ExtensionConfigInterface {
            public function name(): string
            {
                return \FriendsOfBehat\SymfonyExtension\ServiceContainer\SymfonyExtension::class;
            }

            public function toArray(): array
            {
                return ['bootstrap' => 'tests/bootstrap.php'];
            }
        }
    )

Also, Behat 4.0 won't support YAML configuration, so Flex fixtures will need to be adjusted later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants