tomeasterbrook/livewire-fakeable
mount() lifecycle hook, ensuring fake data is injected only locally and only if state is empty, preserving production behavior..env flags). Requires discipline to avoid committing fake data to version control.mount() hook structure. Breaking change risk if upgrading Livewire major versions.@computed). Requires explicit property declaration..env isn’t properly configured). Mitigate with .gitignore for storage/framework/testing/ or CI exclusions.Factory classes).name, email) benefit most.app()->environment('local')) to prevent fake data in tests/staging.composer.json:
composer require tomeasterbrook/livewire-fakeable --dev
AppServiceProvider (if needed for global Faker customization):
use TomEasterbrook\LivewireFakeable\Facades\Fakeable;
Fakeable::extend('user', function () { ... });
use TomEasterbrook\LivewireFakeable\Fakeable;
class UserProfile extends Component {
public string $name;
public string $email;
#[Fakeable]
public function mount() {
// Fake data injected here (locally only)
}
}
.env:
FAKEABLE_ENABLED=true # Local only
.env.testing:
FAKEABLE_ENABLED=false
DatabaseMigrations or RefreshDatabase traits for real test data).fake()->product()).#[Fakeable(enabled: false)]
public string $sensitiveData;
mount() behavior, package may need updates. Monitor Livewire’s RFCs.dd($this->state) to inspect real vs. fake values during development.## Fake Data Warning
This component uses `livewire-fakeable` for local development. **Never rely on fake data in production or tests.**
fake()->persist()).User::factory()->create() in mount()").| Scenario | Impact | Mitigation |
|---|---|---|
| Fake data committed to repo | Tests/CI fail unpredictably | .gitignore storage/framework/ |
| Production data overwritten | None (local-only) | N/A |
| Faker provider errors | Component fails to mount | Fallback to empty state or defaults |
| Livewire major version bump | Package breaks | Pin Livewire version in composer.json |
| Over-reliance on fake data | Untested edge cases in prod | Enforce manual test validation |
How can I help you explore Laravel packages today?