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.
DatabaseSeeder hooks).Factory or Seeder classes could wrap this for tighter integration.Artisan command integration (would require custom CLI commands).Illuminate\Database updates).DatabaseSeeder).DatabaseSeeder or Factories?
Factory system?LaravelFixtureLoader) reduce integration effort?RefreshDatabase)?Artisan command (would need custom implementation).DB::connection()->getPdo() for consistency with Laravel’s connection handling.phpunit/pest but lacks integration with RefreshDatabase or MigrateFresh.FixtureServiceProvider to hook into Laravel’s bootstrapping.php artisan fixture:load).Factory system, using this package only for legacy fixtures.FixtureLoader facade that:
// app/Providers/FixtureServiceProvider.php
public function boot()
{
Fixture::extend(function ($loader) {
$loader->useDatabaseTransactions();
$loader->dispatchEventsAfterLoad();
});
}
| Feature | Package Support | Laravel Support | Integration Notes |
|---|---|---|---|
| Eloquent Models | ✅ Yes | ✅ Native | Direct model instantiation works. |
| Raw SQL Fixtures | ✅ Yes | ❌ No | Use DB::statement() for safety. |
| Batch Loading | ✅ Yes | ❌ No | Manual chunking may be needed. |
| Transactions | ❌ No | ✅ Yes | Add via wrapper (see above). |
| Dependency Injection | ❌ No | ✅ Yes | Bind fixtures to Laravel container. |
| CLI Integration | ❌ No | ✅ Yes | Custom Artisan command required. |
FixtureServiceProvider wrapper.Factory classes.README.md section in the repo for Laravel usage patterns.try-catch blocks and log errors to Laravel’s log system.DB::unprepared()).DB::enableQueryLog() to profile slow fixtures.process() helper for concurrent loading (with caution).| Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Fixture data conflicts | Duplicate records, FK violations | Use DB::transactions() or OnConflict clauses. |
| Package PHP version mismatch | Silent failures or errors | Pin PHP version in composer.json. |
| Database connection issues | Partial loads, timeouts | Retry logic with exponential backoff. |
| Missing dependencies | Fixtures fail to load | Validate all referenced models/classes. |
| No rollback mechanism | Manual cleanup required | Extend wrapper to support fixture:rollback. |
RefreshDatabase).- name: Load fixtures
run: php artisan fixture:load --env=testing
How can I help you explore Laravel packages today?