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

Data Fixture Laravel Package

phpmob/data-fixture

Lightweight PHP package for defining and loading data fixtures to seed databases during development and testing. Helps generate consistent sample records, manage fixture sets, and reset data quickly for repeatable test runs and local environments.

View on GitHub
Deep Wiki
Context7

Just abstraction data fixture.

Frequently asked questions about Data Fixture
How do I install and set up phpmob/data-fixture in a Laravel project?
Run `composer require phpmob/data-fixture` to install. Define fixtures as PHP classes or arrays in your project, then load them via `Fixture::load('path/to/fixture')`. For Laravel integration, create a custom Artisan command (e.g., `php artisan fixture:load`) to bridge the gap with Laravel’s service container.
Does this package support Laravel’s Eloquent models for fixtures?
Yes, you can define fixtures using Eloquent models directly. Instantiate them in your fixture classes or arrays, and the package will handle saving them to the database. However, it lacks Laravel-specific features like model events or observers, so you may need to extend it for full integration.
Will this work with Laravel 9/10 or PHP 8.x?
No, the package was last updated in 2018 and lacks PHP 8.x support (e.g., named arguments, typed properties) and Laravel 9+/10+ compatibility. Use it only for legacy projects or wrap it in a custom loader for modern Laravel versions.
Can I use this for production database seeding?
It’s not recommended. The package lacks transaction support, rollback capabilities, and modern Laravel integrations (e.g., DatabaseSeeder hooks). For production, use Laravel’s built-in Factories or Seeders with transactions enabled.
How do I handle foreign key dependencies between fixtures?
The package doesn’t natively resolve dependencies, so you’ll need to manually order fixtures or use Laravel’s Factories for automatic dependency handling. For complex relationships, consider writing a custom loader that enforces load order or uses transactions.
Does phpmob/data-fixture support JSON or YAML fixture definitions?
No, it only supports PHP classes or arrays. If you need JSON/YAML, consider alternatives like Laravel’s Factories (with JSON-based model definitions) or third-party packages like `orhanerday/faker` for dynamic data generation.
How can I integrate this with Laravel’s DatabaseSeeder?
Create a custom Artisan command or service provider to load fixtures from `DatabaseSeeder`. For example, override the `run()` method to call `Fixture::load()` for each fixture set. This requires manual setup since the package isn’t Laravel-native.
Is there a way to reset or rollback fixtures after testing?
No, the package doesn’t support transactions or rollbacks. For testing, pair it with Laravel’s `RefreshDatabase` trait or use a wrapper that wraps fixture loading in a transaction (e.g., `DB::transaction()`).
What are the alternatives to phpmob/data-fixture for Laravel?
For modern Laravel projects, use built-in **Factories** (with `Faker`) or **Seeders** for Eloquent models. For advanced use cases, consider `laravel-shift/database-seeder` or `spatie/laravel-factories` for more control. If you need JSON/YAML support, explore `mobiledetect/mobiledetectlib` wrappers or custom solutions.
How do I version-control fixture data alongside my Laravel project?
Store fixture definitions as PHP classes or arrays in your project’s `database/fixtures` directory (or similar). Commit these files to version control like any other code. For dynamic data, use Laravel’s Factories with JSON templates or externalize them to a separate repo if sensitive.
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.
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope