Weave Code
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

Eris Laravel Package

giorgiosironi/eris

Property-based testing library for PHP. Generate random inputs, shrink failing cases, and find edge bugs automatically. Eris integrates with PHPUnit to make tests more robust and expressive, inspired by QuickCheck-style generators and combinators.

View on GitHub
Deep Wiki
Context7

PHP library for property-based testing. Integrates with PHPUnit.

Frequently asked questions about Eris
How do I install Eris for Laravel projects?
Run `composer require giorgiosironi/eris --dev` in your Laravel project. Eris integrates with PHPUnit, so no additional Laravel-specific setup is required beyond configuring PHPUnit in your `phpunit.xml`. Ensure your `phpunit.xml` includes the Eris extension under `<extensions>`.
Does Eris work with Laravel’s Eloquent models in property-based tests?
Yes, but you’ll need to handle database transactions carefully. Wrap property-based tests in Laravel’s `refreshDatabase()` or `transaction()` methods to avoid polluting your test database. Eris can generate random model inputs, but ensure your properties account for database constraints.
Which Laravel versions are compatible with Eris?
Eris works with any Laravel version that supports PHPUnit 8.0+. Since Laravel 8+ uses PHPUnit 9+, compatibility is guaranteed. For older Laravel versions (5.8–7.x), verify your PHPUnit version meets Eris’s requirements (8.0+). No Laravel-specific dependencies exist.
How does Eris shrink failing test cases to minimal examples?
Eris automatically generates random inputs and, when a test fails, uses a binary search algorithm to reduce the failing input to the smallest possible example. This helps pinpoint edge cases quickly. Shrinking is built into the property-based testing workflow and doesn’t require manual configuration.
Can I use Eris alongside Laravel’s built-in testing tools like `create()` or factories?
Absolutely. Eris can generate random data for factories or model `create()` calls, making it ideal for testing edge cases in your Laravel application. Combine it with Laravel’s `DatabaseMigrations` or `RefreshDatabase` traits to ensure clean test environments for property-based checks.
Are there performance concerns when running Eris tests in CI?
Property-based tests may run slower than traditional unit tests due to random input generation and shrinking. Limit test iterations in CI using Eris’s `--iterations` flag or focus on critical properties. For large projects, prioritize high-impact properties to balance speed and coverage.
What’s the difference between Eris and traditional Laravel test assertions?
Traditional assertions test specific inputs, while Eris verifies *properties* your code should satisfy for *any* input. For example, instead of testing `User::validate(['email' => 'test@example.com'])`, you’d define a property like ‘all valid emails should pass validation,’ letting Eris find edge cases like malformed emails.
How do I write a property-based test for a Laravel API endpoint?
Define a property function that generates random input data (e.g., JSON payloads) and asserts the endpoint’s response meets expectations. Use Laravel’s `Http::fake()` or `actingAs()` to mock auth, then let Eris generate varied requests. Example: `assertTrue(fn() => Http::post('/api/users', $randomData)->json('success'))`.
Does Eris support testing Laravel queues or jobs?
Yes, but you’ll need to mock queue workers or use Laravel’s `Queue::fake()`. Generate random job payloads with Eris and assert queue behavior (e.g., job dispatching, failure handling). For example, test that a job always processes valid data by defining a property like ‘invalid payloads should trigger job failures.’
What alternatives exist to Eris for property-based testing in Laravel?
For PHP, Eris is the most mature option. Alternatives include custom solutions using PHPUnit’s data providers or libraries like `phpunit-data-provider`, but they lack Eris’s shrinking and random generation. For other languages, tools like Hypothesis (Python) or QuickCheck (Haskell) exist, but none match Eris’s PHPUnit integration.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport