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
Fixture Handler

Fixture Handler Laravel Package

dansan/fixture-handler

Laravel helper for managing fixtures/test data. Load, reset, and organize fixture sets to seed databases quickly during development and automated tests, keeping sample data consistent across environments.

View on GitHub
Deep Wiki
Context7

A module to handle fixtures in tests

Frequently asked questions about Fixture Handler
How does dansan/fixture-handler compare to Laravel’s built-in DatabaseSeeder or Factories for managing test data?
This package is designed for teams needing more control over fixture organization, especially with custom formats like JSON/YAML/CSV. Unlike Factories, it loads pre-defined datasets, making it ideal for complex or static test data. Use it alongside Factories for hybrid approaches—Factories for dynamic data, fixtures for static or third-party datasets.
Can I use this package with Laravel 10+ and PHP 8.2+? What’s the compatibility like?
The package supports PHP 8.x but may lag behind Laravel 10+ due to limited maintenance. Check the repository’s PHP version constraints in `composer.json` and test thoroughly with your Laravel version. If compatibility issues arise, consider forking or using a wrapper for backward compatibility.
How do I load fixtures dynamically per test case instead of seeding the entire database?
The package allows loading specific fixture sets on demand. Use its API methods (e.g., `FixtureHandler::load('users')`) within test setup methods like `setUp()` or `beforeEach()`. This avoids seeding the entire database and keeps tests isolated. Example: `FixtureHandler::load('admin_users')->run();` in a test class.
Does this package work with SQLite for testing, or is it MySQL/PostgreSQL-specific?
The package is database-agnostic and works with SQLite, MySQL, or PostgreSQL as long as your Laravel configuration points to the correct connection. However, test performance may vary—SQLite is faster for unit tests, while MySQL/PostgreSQL might be needed for integration tests mirroring production.
How do I structure my fixtures directory to avoid conflicts with Laravel’s migrations?
Organize fixtures in a dedicated `database/fixtures/` directory (or `tests/Fixtures/`). Use clear naming conventions (e.g., `users.json`, `posts_with_authors.yaml`) and avoid hardcoding IDs. Sync fixture updates with migrations by running `php artisan migrate:fresh` before loading fixtures in tests.
Will using this package slow down my test suite compared to Laravel’s RefreshDatabase?
It depends on fixture complexity. Bulk-loading large datasets (e.g., CSV) may add overhead, but the package is optimized for speed. For performance-critical tests, load only necessary fixtures or use `RefreshDatabase` for full resets. Benchmark both approaches in your CI pipeline to compare.
Can I use this package with PestPHP or is it PHPUnit-only?
The package is framework-agnostic and works with both PHPUnit and PestPHP. Use its methods in Pest’s `beforeEach` or `beforeAll` hooks just like you would in PHPUnit’s `setUp()`. Example: `beforeEach(fn() => FixtureHandler::load('users')->run());` in Pest tests.
How do I handle fixture updates when database schema changes (e.g., new columns or tables)?
Update your fixture files manually to match the new schema, then run `php artisan migrate:fresh` to apply changes. For automated syncing, consider a pre-test hook that validates fixtures against migrations. Example: Use a custom Artisan command to compare fixture structure with the latest schema.
Are there any security risks if I load fixtures from user-provided data (e.g., API contract testing)?
Yes—always sanitize or validate fixtures before loading, especially if they come from untrusted sources. Use Laravel’s validation rules or a whitelist of allowed fields. Avoid executing raw SQL from fixtures; stick to supported formats (JSON/YAML/CSV) and let the package handle parsing.
What’s the best way to integrate this package into a CI/CD pipeline for faster test runs?
Cache fixtures in CI by storing them in a shared volume or artifact between test runs. Use Laravel’s `config('fixture-handler.cache')` (if supported) or pre-load fixtures in a `beforeAll` hook. For Dockerized environments, mount the fixtures directory as a volume to avoid re-downloading files.
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui