Making Fixtures Really Awesome with Alice

Buy Access

Fixtures: those little bits of test data you load (and reload) locally so that you can test your site with some real-ish content. Until now, creating fixtures was boring. But with Alice, they're video-game-level exciting. Seriously!


Your Guides

Ryan Weaver Leanna Pelham

Questions? Conversation?

  • 2017-03-28 Victor Bocharsky

    Hey Martin,

    Glad you got it working so fast! Docs FTW! :)

    Cheers!

  • 2017-03-27 Martin Bittner

    I finally got it to work, following Alice-Bundle instructions!

  • 2017-03-27 Martin Bittner

    Well,

    Here is my composer.json
    "require": {
    "php": ">=5.5.9",
    "symfony/symfony": "3.2.*",
    "doctrine/orm": "^2.5",
    "doctrine/doctrine-bundle": "^1.6",
    "doctrine/doctrine-cache-bundle": "^1.2",
    "symfony/swiftmailer-bundle": "^2.3.10",
    "symfony/monolog-bundle": "^3.0.2",
    "symfony/polyfill-apcu": "^1.0",
    "sensio/distribution-bundle": "^5.0",
    "sensio/framework-extra-bundle": "^3.0.2",
    "incenteev/composer-parameter-handler": "^2.0",
    "twig/twig": "^1.0||^2.0"
    },
    "require-dev": {
    "sensio/generator-bundle": "^3.0",
    "symfony/phpunit-bridge": "^3.0",
    "nelmio/alice": "3.0.*@beta",
    "hautelook/alice-bundle": "2.0.*@beta",
    "theofidry/alice-data-fixtures": "1.0.*@beta",
    "doctrine/data-fixtures": "^1.2",
    "doctrine/doctrine-fixtures-bundle": "^2.3"
    },

    I tried with creating a fixture class in php like in the tutorial and adding my .yml in it and used app/console doctrine:fixtures:load, it does ask me if I want to purge my data, I say yes, and the prompt returns without error, and no data in DB.

    Then I look at the alice bundle doc, and added
    # app/config/config_dev.yml

    hautelook_alice:
    fixtures_path: 'Resources/fixtures/orm' # Path to which to look for fixtures relative to the bundle path.

    and tried using bin/console hautelook:fixtures:load and samething happens, purge data prompt, then the prompt returns without error and no DB.

    Can you spot anything wrong?

  • 2017-03-27 Victor Bocharsky

    Hey Martin,

    Yes, it can be. What version do you use? Many concepts are the same, but they change something in the new version. What command do you run to load your fixtures? What output exactly do you have after this command?

    Cheers!

  • 2017-03-26 Martin Bittner

    I followed this tutorial, and nothing loads into my DB, yet no error displayed. Any idea? Can it be linked to the newer version of the HautelookAliceBundle?

  • 2015-01-21 weaverryan

    Hey there!

    Actually, I don't think this is possible right now - that value is "locked up" in a class from "Alice" that we can't access. You *can* use most of the Faker functions inside your custom formatter/provider by creating your own Faker instance:


    $faker = \Faker\Factory::create('en');
    var_dump($faker->company);

    But current() is the *one* formatter that's different, and we can't get to it. You also can't nest formatters (e.g. <avatar(<current()>)>, which would be kind of cool :).

    Cheers!

  • 2015-01-21 xdrew

    Is there any easy way to get access to current() in my custom provider?