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

Alice Bundle Laravel Package

byvlad/alice-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require hautelook/alice-bundle
    

    Add to config/bundles.php (Symfony 4+):

    Hautelook\AliceBundle\HautelookAliceBundle::class => ['all' => true],
    
  2. First Fixture Create a YAML file (e.g., config/fixtures/users.yml):

    App\Entity\User:
      user{1..10}:
        email: '<email()>'
        roles: ['ROLE_USER']
        plainPassword: 'password'
    

    Load fixtures via CLI:

    php bin/console hautelook:fixtures:load --env=test
    
  3. Database Support Ensure FidryAliceDataFixtures is installed (handles Doctrine ORM, Propel, etc.):

    composer require theofidry/alice-data-fixtures
    

Implementation Patterns

Workflow Integration

  1. Test Environments Use in phpunit.xml for test databases:

    <env name="DATABASE_URL" value="sqlite:///:memory:"/>
    

    Load fixtures before tests via setUp():

    public function setUp(): void {
        $this->loadFixtures(['users.yml', 'posts.yml']);
    }
    
  2. Dynamic Fixtures Generate fixtures programmatically:

    $faker = Faker\Factory::create();
    $users = [];
    for ($i = 0; $i < 5; $i++) {
        $users[] = new User([
            'email' => $faker->email,
            'roles' => ['ROLE_USER']
        ]);
    }
    $this->loadFixtures([$users]);
    
  3. Dependency Injection Inject AliceDataFixtures service in controllers/services:

    use Hautelook\AliceBundle\Loader\LoaderInterface;
    
    public function __construct(LoaderInterface $loader) {
        $this->loader = $loader;
    }
    

Common Patterns

  • Reusable Fixtures: Split fixtures into modular YAML files (e.g., users.yml, posts.yml) and load them together.
  • Environment-Specific Fixtures: Use --env flag to load different fixtures per environment.
  • Seeding Production: Disable in production (use --no-warmup flag or environment checks).

Gotchas and Tips

Pitfalls

  1. Database Constraints

    • Foreign Keys: Ensure referenced entities exist before loading dependent fixtures (order matters).
    • Unique Fields: Use <uniqueEmail()> or custom Faker providers to avoid duplicates.
  2. Caching Issues

    • Clear cache after schema changes:
      php bin/console cache:clear
      
  3. ORM-Specific Quirks

    • Doctrine: Use FidryAliceDataFixtures\Loader\DoctrineLoader for complex relationships.
    • Propel: Configure propel:model:build to regenerate models after fixture changes.

Debugging Tips

  • Verbose Output: Enable debug mode for detailed logs:
    php bin/console hautelook:fixtures:load --env=test --debug
    
  • Dry Run: Test without loading:
    php bin/console hautelook:fixtures:load --env=test --dry-run
    
  • Custom Providers: Extend Faker for domain-specific data:
    Faker\Factory::create()->extend('customProvider', function ($faker) {
        return function () {
            return 'custom_' . $faker->word;
        };
    });
    

Extension Points

  1. Custom Loaders Implement Hautelook\AliceBundle\Loader\LoaderInterface for non-Doctrine databases (e.g., Eloquent).
  2. Post-Load Hooks Use Symfony events (kernel.terminate) to run logic after fixture loading.
  3. Parameterized Fixtures Pass runtime values via CLI arguments:
    php bin/console hautelook:fixtures:load --env=test --param="users.count=20"
    
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky