GithubHelp home page GithubHelp logo

alice's Introduction

Alice - Expressive fixtures generator

Package version Build Status SensioLabsInsight Dependency Status Gitter License

Relying on fzaninotto/Faker, Alice allows you to create a ton of fixtures/fake data for use while developing or testing your project. It gives you a few essential tools to make it very easy to generate complex data with constraints in a readable and easy to edit way, so that everyone on your team can tweak the fixtures if needed.

Warning: this doc is being updated for alice 3.0. If you want to check the documentation for 2.x, head this way.

Table of Contents

  1. Installation
  2. Example
  3. Getting Started
  4. Basic Usage
  5. Framework integration 1. Symfony
  6. Complete Reference
  7. Creating Fixtures 1. YAML 1. PHP
  8. Fixture Ranges
  9. Calling Methods
  10. Specifying Constructor Arguments
  11. Optional Data
  12. Handling Unique Constraints
  13. Handling Relations
  14. References
  15. Multiple References
  16. Self reference
  17. Passing references to providers
  18. Keep Your Fixtures Dry
  19. Fixture Inheritance
  20. Including files
  21. Variables
  22. Parameters
  23. Customize Data Generation
  24. Faker Data
  25. Localized Fake Data TODO: port that change to v2
  26. Default Providers 1. Identity
  27. Reuse generated data using objects value
  28. Custom Faker Data Providers
  29. Third-party libraries
  30. Contribute
  31. Upgrade
  32. License

Other references:

Installation

This is installable via Composer as nelmio/alice:

composer require --dev nelmio/alice

Example

Here is a complete example of entity declaration:

Nelmio\Entity\User:
    user{1..10}:
        username: '<username()>'
        fullname: '<firstName()> <lastName()>'
        birthDate: '<date()>'
        email: '<email()>'
        favoriteNumber: '50%? <numberBetween(1, 200)>'

Nelmio\Entity\Group:
    group1:
        name: Admins
        owner: '@user1'
        members: '<numberBetween(1, 10)>x @user*'
        created: '<dateTimeBetween("-200 days", "now")>'
        updated: '<dateTimeBetween($created, "now")>'

You can then load them easily with:

$loader = new Nelmio\Alice\Loader\NativeLoader();
$objectSet = $loader->loadFile(__DIR__.'/fixtures.yml');

Or load an array right away:

$loader = new Nelmio\Alice\Loader\NativeLoader();
$objectSet = $loader->loadData([
    \Nelmio\Entity\User::class => [
        'user{1..10}' => [
            'username' => '<username()>',
            'fullname' => '<firstName()> <lastName()>',
            'birthDate' => '<date()>',
            'email' => '<email()>',
            'favoriteNumber' => '50%? <numberBetween(1, 200)>',
        ],
    ],
    \Nelmio\Entity\Group::class => [
        'group1' => [
            'name' => Admins,
            'owner' => '@user1',
            'members' => '<numberBetween(1, 10)>x @user*',
            'created' => '<dateTimeBetween("-200 days", "now")>',
            'updated' => '<dateTimeBetween($created, "now")>',
        ],
    ],
]);

For more information, refer to the documentation.

Third-party libraries

Contribute

Check the contribution guide.

Upgrade

Check the upgrade guide.

License

Released under the MIT License.

alice's People

Contributors

addfs avatar ajessu avatar baldurrensch avatar bendavies avatar benji07 avatar devster avatar digitalkaoz avatar dmecke avatar docteurklein avatar enumag avatar everzet avatar gquemener avatar grobx avatar h4cc avatar herzult avatar jubianchi avatar kalifg avatar knugen avatar marekkalnik avatar markcial avatar munkie avatar nikita2206 avatar pedrotroller avatar rdubigny avatar seldaek avatar sobit avatar soullivaneuh avatar theofidry avatar tshelburne avatar umpirsky avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.