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
Laravel Dummy Models

Laravel Dummy Models Laravel Package

cetria/laravel-dummy-models

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Laravel Dummy Models
How do I use cetria/laravel-dummy-models to replace a real database in unit tests?
Extend the `DummyModel` class and define fillable fields, then use `DummyModel::make()` to create fake instances. For example, `UserDummy::make(['name' => 'Test'])` generates a dummy user without hitting a database. This is ideal for isolated unit tests where database interactions aren’t needed.
Does this package work with Laravel’s built-in factories (Model::factory())?
No, it’s an alternative. While `Model::factory()` is more feature-rich (e.g., state definitions, afterCreating hooks), this package is lighter and doesn’t require database migrations. Choose based on your needs: use factories for complex test data, dummy models for pure mocking.
Can I use dummy models in integration tests where database persistence is required?
No, dummy models are in-memory only and won’t persist to a database. For integration tests needing real interactions, stick to Laravel’s factories or database transactions. Dummy models are best for unit tests or API contract testing where persistence isn’t critical.
What Laravel versions and PHP versions does cetria/laravel-dummy-models support?
The package requires **PHP 7.4+** and is designed for **Laravel 8+**. It leverages Eloquent’s core features, so it won’t work with older Laravel versions (e.g., 5.x) or PHP 7.3 or below. Always check the package’s `composer.json` for the latest compatibility.
How do I handle relationships (e.g., hasMany, belongsTo) with dummy models?
You can manually define relationships in your dummy model class, but the package doesn’t auto-generate them. For example, add `public function posts() { return $this->hasMany(PostDummy::class); }` to a `UserDummy` class. This works for basic mocking but lacks Laravel’s factory relationship features.
Will dummy models slow down my test suite if I generate complex data?
Dummy models are lightweight, but generating thousands of nested objects (e.g., recursive relationships) could introduce overhead. For performance-critical tests, limit dummy model usage to essential cases or use Laravel’s factories with database transactions instead.
Can I use cetria/laravel-dummy-models in development instead of a real database?
Technically yes, but it’s **not recommended** for production-like development. Dummy models lack validation, persistence, and business logic. Use them only for prototyping or isolated feature exploration. For development, consider SQLite or Laravel’s `fresh()` method with factories.
How do I avoid conflicts between dummy models and real models in the same codebase?
Use distinct class names (e.g., `UserDummy` vs. `User`) and namespace them under a `Tests` or `Dummy` folder. Also, check the environment (e.g., `if (app()->environment('testing'))`) to ensure dummy models only load in test contexts.
Are there any alternatives to cetria/laravel-dummy-models for fake Eloquent models?
Yes. Laravel’s built-in `Model::factory()` is the most robust option for test data, while packages like `laravel-shift/dummy-faker` or `fzaninotto/faker` (with custom Eloquent models) offer similar functionality. Evaluate based on your needs: use factories for complex data, dummy models for pure mocking.
Is cetria/laravel-dummy-models actively maintained? Should I use it in production?
The package appears low-traffic (check Bitbucket activity or GitHub mirrors for updates). It’s **not suitable for production**—only for testing or prototyping. For production, use real models with migrations. If maintenance is a concern, consider Laravel’s native tools or more popular alternatives.
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.
htinlynn/genius-helper
maco-studios/hephaestus
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator