PHPackages                             kulturman/laravel-alice - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. kulturman/laravel-alice

ActiveLibrary[Database &amp; ORM](/categories/database)

kulturman/laravel-alice
=======================

YAML-based fixture loading for Laravel using nelmio/alice with Eloquent persistence

v1.0.0(1mo ago)017↓20%MITPHPPHP ^8.3CI passing

Since May 2Pushed 1mo agoCompare

[ Source](https://github.com/kulturman/Laravel-alice)[ Packagist](https://packagist.org/packages/kulturman/laravel-alice)[ RSS](/packages/kulturman-laravel-alice/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

Laravel Alice
=============

[](#laravel-alice)

YAML-based fixture loading for Laravel, powered by [nelmio/alice](https://github.com/nelmio/alice) and [theofidry/alice-data-fixtures](https://github.com/theofidry/AliceDataFixtures).

Requirements
------------

[](#requirements)

- PHP 8.3+
- Laravel 11+

Installation
------------

[](#installation)

```
composer require kulturman/laravel-alice
```

Publish the configuration file:

```
php artisan vendor:publish --tag=alice-config
```

Configuration
-------------

[](#configuration)

```
// config/alice.php

return [
    'fixtures_path' => database_path('fixtures'),
    'purge_mode' => 'delete', // delete | truncate | none
    'excluded_tables' => ['migrations', 'jobs', 'failed_jobs'],
    'providers' => [
        // Custom Faker providers:
        // App\Fixtures\Providers\MyProvider::class,
    ],
];
```

Writing Fixtures
----------------

[](#writing-fixtures)

Create YAML files in `database/fixtures/`:

```
# database/fixtures/companies.yaml
App\Models\Company:
    company_acme:
        name: "Acme Corp"
    company_{1..10}:
        name: ""
```

```
# database/fixtures/users.yaml
App\Models\User:
    user_admin:
        name: "Admin"
        email: "admin@example.com"
        company_id: 1
    user_{1..50}:
        name: " "
        email: ""
        company_id: ""
```

For the full YAML reference, see the [nelmio/alice documentation](https://github.com/nelmio/alice/blob/master/doc/complete-reference.md).

Usage
-----

[](#usage)

### Artisan Command

[](#artisan-command)

```
# Load all fixtures (with purge confirmation)
php artisan alice:fixtures:load

# Append without purging
php artisan alice:fixtures:load --append

# Use truncate instead of delete
php artisan alice:fixtures:load --purge=truncate

# Load from a custom path
php artisan alice:fixtures:load --path=database/fixtures/dev

# Skip confirmation
php artisan alice:fixtures:load --no-interaction
```

### In Tests

[](#in-tests)

Two traits are available depending on how much control you need:

#### `WithFixtures` — automatic loading

[](#withfixtures--automatic-loading)

Fixtures are loaded automatically before each test. Global fixtures from the configured path are always loaded, and a per-test fixture file is loaded if it exists next to the test class (e.g. `OrderTest.yaml` alongside `OrderTest.php`).

```
use Kulturman\LaravelAlice\Testing\WithFixtures;

class OrderTest extends TestCase
{
    use RefreshDatabase, WithFixtures;

    public function test_order_total(): void
    {
        // $this->fixtures contains all persisted models
        // Global fixtures + OrderTest.yaml (if it exists) are already loaded
    }
}
```

```
# tests/OrderTest.yaml — loaded only for OrderTest
App\Models\Order:
    order_1:
        user_id: 1
        total: 150
```

#### `UseFixtures` — manual loading

[](#usefixtures--manual-loading)

For fine-grained control, use `UseFixtures` and call `loadFixtures()` explicitly:

```
use Kulturman\LaravelAlice\Testing\UseFixtures;

class OrderTest extends TestCase
{
    use RefreshDatabase, UseFixtures;

    public function test_order_total(): void
    {
        // Load all fixtures from the configured path
        $objects = $this->loadFixtures();

        // Or load specific files
        $objects = $this->loadFixtures([
            database_path('fixtures/companies.yaml'),
            database_path('fixtures/users.yaml'),
        ]);

        // $objects is an array of persisted models indexed by fixture name
        $this->assertNotEmpty($objects);
    }
}
```

### Custom Faker Providers

[](#custom-faker-providers)

Create a provider class and register it in the config:

```
namespace App\Fixtures\Providers;

use Faker\Provider\Base;

class ProductProvider extends Base
{
    public function sku(): string
    {
        return 'SKU-' . $this->generator->unique()->numberBetween(10000, 99999);
    }
}
```

```
// config/alice.php
'providers' => [
    App\Fixtures\Providers\ProductProvider::class,
],
```

Then use it in fixtures:

```
App\Models\Product:
    product_{1..100}:
        sku: ""
        name: ""
```

License
-------

[](#license)

MIT

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance92

Actively maintained with recent releases

Popularity8

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

38d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e3a089ba0216277d6496bd2600093b0ac075091e2af8c7c02e0f9d5cc233193?d=identicon)[kulturman](/maintainers/kulturman)

---

Top Contributors

[![kulturman](https://avatars.githubusercontent.com/u/11850979?v=4)](https://github.com/kulturman "kulturman (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/kulturman-laravel-alice/health.svg)

```
[![Health](https://phpackages.com/badges/kulturman-laravel-alice/health.svg)](https://phpackages.com/packages/kulturman-laravel-alice)
```

###  Alternatives

[larastan/larastan

Larastan - Discover bugs in your code without running it. A phpstan/phpstan extension for Laravel

6.4k51.0M7.4k](/packages/larastan-larastan)[spatie/laravel-medialibrary

Associate files with Eloquent models

6.1k41.3M594](/packages/spatie-laravel-medialibrary)[laravel/ai

The official AI SDK for Laravel.

9782.1M153](/packages/laravel-ai)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

436834.4k1](/packages/clickbar-laravel-magellan)[itpathsolutions/dbstan

Database Standardization and Analysis Tool for Laravel

442.1k](/packages/itpathsolutions-dbstan)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
