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
Phpspec Laravel

Phpspec Laravel Laravel Package

benconstable/phpspec-laravel

phpspec-laravel adds Laravel-aware testing to phpspec, bootstrapping your app and providing matchers and helpers for Eloquent models, routes, views, and more so you can write expressive specs for Laravel code.

View on GitHub
Deep Wiki
Context7

Test your Laravel applications with PhpSpec

Frequently asked questions about Phpspec Laravel
What is benconstable/phpspec-laravel used for?
phpspec-laravel is a phpspec extension that adds Laravel-aware testing to your specs. It bootstraps the Laravel application inside the phpspec runner and provides matchers and helpers for Eloquent models, routes, views, and other framework components. That lets you write expressive, Laravel-fluent specs instead of raw assertions in a plain phpspec setup.
How do I install phpspec-laravel in a Laravel application?
Install it as a dev dependency with Composer, pinning 4.0.1 rather than 4.0.0 since the first 4.x release shipped a broken vendor path. Then register the package's extension in your phpspec.yml and point phpspec at your application bootstrap. After installing, run your suite and verify that any published config or asset paths still resolve correctly.
Which Laravel and PHP versions does phpspec-laravel 4.x support?
A major version bump like 3.x to 4.x is a natural moment for a minimum PHP or Laravel floor bump, so treat the move as a possible constraint change rather than a drop-in patch. Check the composer.json require constraints for the exact PHP and illuminate/support ranges before committing. Confirm your application versions sit inside that matrix before upgrading.
What changed in phpspec-laravel 4.0.1?
The sole documented change in 4.0.1 is a fix for a broken vendor path introduced by the migration to PSR-4 autoloading. In other words, 4.0.0 changed how classes map to directories and where the package lives inside vendor/, and the first cut of that change was defective for installed consumers. Adopting 4.0.1 avoids the known-broken artifact.
How do I upgrade phpspec-laravel from 3.x to 4.x?
The core change is PSR-4 autoloading, which shifts the package's on-disk location inside vendor/ and therefore any path computed from it. Audit deploy scripts, Dockerfiles, CI steps, phpunit.xml or phpspec bootstrap paths, and composer.json path repositories for hardcoded vendor paths, then regenerate optimized or authoritative autoloaders so stale classmaps do not linger. Finally, verify published config, asset, and migration paths still resolve to the right place.
What matchers and helpers does phpspec-laravel provide?
The package provides Laravel-aware matchers and helpers covering Eloquent models, routes, views, and additional framework concerns. They are designed so your specs read expressively, describing expected framework behavior rather than asserting on raw arrays or response internals. Check the README for the current matcher list, since the 4.x line may have adjusted details.
Can I use phpspec-laravel alongside PHPUnit or Pest?
Yes. phpspec is a design and specification tool, while PHPUnit or Pest typically carry your feature and integration coverage, so using both is common in Laravel projects. phpspec-laravel only makes phpspec Laravel-aware; it does not replace a browser-level or database-backed test suite. Keep the heavier framework tests in PHPUnit or Pest and use phpspec for unit-level design feedback.
How do I write a spec for an Eloquent model with phpspec-laravel?
Describe the class under spec, instantiate it directly or with doubled collaborators, and use the package's Laravel-aware matchers to express expectations about model behavior and relationships. Because the extension bootstraps the application, framework services are available during the spec run without manual wiring. Keep database-touching behavior out of specs where possible and push it into integration tests.
Where do I configure phpspec-laravel and its bootstrapping?
Configuration lives in phpspec.yml, where you register the extension and define the bootstrap that loads your Laravel application. In 4.x, published config and asset paths shifted with the PSR-4 directory layout, so re-check any path references after upgrading. If the app fails to boot under phpspec, the vendor path and autoloader are the first things to verify.
Is phpspec-laravel 4.x safe for production use, and what are the alternatives?
The 4.0.1 defect is install-time rather than runtime, and a broken vendor path normally fails loudly at boot or during vendor:publish, which is cheap to catch in a staging deploy. The more concerning signal is that a packaging defect reached a release, so consider a short soak period and check the maintainer's issue responsiveness and test matrix across Laravel and PHP versions. Alternatives include plain phpspec without Laravel integration, or PHPUnit and Pest with Laravel's built-in testing helpers.
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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib