Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Page Object Extension

Page Object Extension Laravel Package

friends-of-behat/page-object-extension

Behat extension providing base Page and Element classes for the page object pattern, plus SymfonyPage for straightforward Symfony support. Extracted from Sylius and inspired by SensioLabs, it helps structure and reuse your acceptance test code.

View on GitHub
Deep Wiki
Context7

FriendsOfBehat PageObjectExtension brings the Page Object pattern to Behat test suites, offering base classes to model pages and their reusable fragments instead of scattering selectors throughout step definitions. It draws on concepts proven in the Sylius Behat system and sensiolabs' page object extension.

  • Page — represents a specific web or API page
  • Element — models a reusable part of a page
  • SymfonyPage — adds straightforward Symfony application support
  • Cleaner, more maintainable step definitions
  • Installed as a dev dependency via Composer
Frequently asked questions about Page Object Extension
What is friends-of-behat/page-object-extension?
It is a Behat extension that provides base Page, Element and SymfonyPage classes for the Page Object pattern. The concept was extracted from Sylius and inspired by SensioLabs. It is intended to keep Behat acceptance suites organized by moving selectors and page interactions into reusable classes.
Do I need Behat to use this package in a Laravel project?
Yes. The package is a Behat extension and requires Behat, Gherkin scenarios, context classes and a separate acceptance-test suite. If Behat is not already part of your Laravel workflow, adopting this package means adopting Behat as a process decision, not just installing a Composer dependency. Laravel teams using only PHPUnit, Pest or Dusk are usually a poor fit.
Is SymfonyPage compatible with Laravel routing and the service container?
No, not as a drop-in. SymfonyPage is explicitly Symfony-oriented and assumes Symfony service container, routing and form handling. Laravel shares DI and routing concepts, but you would need a custom LaravelPage adapter or use the generic Page class. A Laravel adapter should resolve routes via Laravel's route helper and access Laravel's container.
How do I install friends-of-behat/page-object-extension in a Laravel project?
Install it as a development dependency with composer require friends-of-behat/page-object-extension --dev. You must already have Behat configured with a Laravel-specific context before the page object classes are useful. Then create Laravel-specific page or element classes extending the package base classes or the generic Page and Element classes.
Does this package support PHP 8 and which Behat versions work with it?
PHP 8 is reported as supported in the changelog, but Behat version compatibility must be verified against your project's Behat version. The package is small and stable in concept, but release provenance and actual activity should be checked before relying on it. Do not assume compatibility with newer Behat releases without testing.
How do I use Page and Element classes for Laravel acceptance tests?
Use Page to represent a specific page or API resource and Element to represent a reusable part of a page, such as a navigation bar or form. Move repeated selectors, navigation and form interactions into those classes and keep Gherkin scenarios business-readable. For Laravel, create a LaravelPage base class that extends Page or SymfonyPage and resolves routes through Laravel.
Is this package worth using with Laravel Dusk or Pest instead of Behat?
It is a poor fit if your Laravel team uses only PHPUnit, Pest or Dusk. The package requires Behat and adds a second test runner and reporting path to CI. A hybrid option is to keep Dusk or Pest for low-level and browser tests and use Behat with this package only for high-value business-readable scenarios.
How should I test and maintain page objects in CI?
Run the Behat suite as an additional CI job alongside PHPUnit or Pest tests, and keep Gherkin scenarios focused on business behavior rather than selectors. Audit existing tests for repeated selectors, navigation and form interactions before refactoring them into page objects. Pilot on one critical Laravel journey before moving all tests to the pattern.
What are the alternatives to this package for Laravel page objects?
Alternatives include a small internal base class of roughly 20 to 50 lines, sensiolabs/BehatPageObjectExtension, or Laravel Dusk page objects with Pest or PHPUnit. The build-versus-buy case matters because this package removes very little boilerplate and mainly enforces a pattern. If Behat is already mandated, reusing this package may standardize page object structure.
Is the package actively maintained and safe for production test suites?
Maintenance signals are mixed: the repository has 177 stars and 0 dependents, and the changelog shows v0.3.2 in 2020 despite a reported 2026-06-12 release that should be verified. Low adoption means fewer community answers, forks and real-world Laravel examples. The code risk is low because the abstraction is small, but the main risk is investing in Behat plus page objects without enough ROI.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core