Expressive fixtures generator

Overview

Alice - Expressive fixtures generator

Package version Build Status Slack License

Relying on FakerPHP/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 for alice 3.0. If you want to check the documentation for 2.x, follow this link.

2.x is in maintenance mode: PRs are accepted, but no active development is done on it by the maintainers any longer.

Table of Contents

  1. Installation
  2. Example
  3. Getting Started
    1. Basic Usage
    2. Framework integration
      1. Symfony
  4. Complete Reference
    1. Creating Fixtures
      1. YAML
      2. PHP
      3. JSON
    2. Fixture Ranges
    3. Fixture Lists
    4. Fixture Reference
    5. Calling Methods
      1. Method arguments with flags
      2. Method arguments with parameters
    6. Specifying Constructor Arguments
    7. Using a factory / a named constructor
    8. Optional Data
    9. Handling Unique Constraints
  5. Handling Relations
    1. References
    2. Multiple References
    3. Self reference
    4. Passing references to providers
  6. Keep Your Fixtures Dry
    1. Fixture Inheritance
    2. Including files
    3. Variables
    4. Parameters
      1. Static parameters
      2. Dynamic parameters
      3. Composite parameters
      4. Usage with functions (constructor included)
      5. Inject external parameters
  7. Customize Data Generation
    1. Faker Data
      1. Localized Fake Data
      2. Random data
      3. Default Providers
        1. Identity
        2. Current
        3. Cast
    2. Custom Faker Data Providers
  8. Advanced Guide
    1. Performance
    2. Expression Language (DSL)
      1. Parameters
      2. Functions
      3. Identity
      4. Arrays
      5. Optional
      6. References
      7. Property Reference
    3. Extending Alice
      1. Custom Flag
      2. Custom Instantiation
      3. Custom Accessor
  9. Third-party libraries
    1. Symfony
    2. Nette
    3. Zend Framework 2
    4. Framework Agnostic
  10. Contribute
    1. Differences between 2.x and 3.x
    2. Architecture
      1. FixtureBuilder
      2. Generator
    3. Expression Language
    4. Contributing
      1. Testing
      2. Profiling
  11. Backward Compatibility Promise (BCP)
  12. Upgrade
    1. Breaking changes between Alice 2.x and 3.0

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_create()>'
        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_create()>',
            '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

Framework Agnostic

Symfony

Nette

WordPress

Zend Framework 2:

Contribute

Check the contribution guide.

Backward Compatibility Promise (BCP)

The policy is for the major part following the same as Symfony's one with a few changes or highlights:

  • Code marked with @private or @internal are excluded from the BCP
  • Nelmio\Alice\Loader\NativeLoader is excluded from the BCP: as it is the no DIC solution, registring a new service may require a new method, in which case your code may break if you have already declared that method. To avoid that, please beware of the naming of your methods to avoid any conflicts.

Upgrade

Check the upgrade guide.

Comments
  • [v3] Roadmap

    [v3] Roadmap

    EDIT: update this part of the message to avoid to have to crawl the whole thread to get a review of v3.

    Main changes with v3:

    • Drop the persistence layer
    • Make the library more resilient
    • Make the library more extendable
    • Make the library more performant
    • Add a few new features & bugfixes

    Global overview of the library:

    screen shot 2016-06-04 at 00 08 25

    Main interfaces (#381):

    LoaderInterface::load(string $file, array $parameters = [], array $objects = []): ObjectSet;
    
    FixtureBuilderInterface::build(string $file, array $parameters = [], array $objects = []): FixtureSet;
    GeneratorInterface::generate(FixtureSet $fixtureSet): ObjectSet;
    
    • [x] Loader (#384)

    FixtureBuilder secondary interfaces (#382):

    • [x] Parser(#361, #385)
    • Denormalizer
      • [x] Fixture (#394)
      • [x] Parameter (#386)

    Generator secondary interfaces (#383):

    • [x] Generator (#395)
    • Resolver
      • [x] Main resolver (#404)
      • [x] Parameters (#366, #396)
      • [x] Fixtures (#397)
    • [x] Instantiator (#440)
    • [x] Specs Resolver (#449)
    • [x] Populator (#442, #450)
    • [ ] Configurator

    –––

    (original message)

    What's your plans @tshelburne? I would be more than happy to work on it :)

    RFC 
    opened by theofidry 33
  • 3.x — as no identity/no id values set. It cannot be added to the identity map.

    3.x — as no identity/no id values set. It cannot be added to the identity map.

    I have two entities.

    user (entity 1)

    • id (primary key)
    • name

    detail (entity 2)

    • user (primary key, which is from user entity)
    • address

    When running fixtures with

    detail_{1..10}:
        user:             "@user_<current()>"
    

    I get the following error

    [Doctrine\ORM\ORMInvalidArgumentException]
    The given entity of type 'AppBundle\Entity\Detail' (AppBundle\Entity\Detail@0000000007f1464d000000006748ef3
    e) has no identity/no id values set. It cannot be added to the identity map.

    Please note that this was working fine on 2.x

    Stackoverflow links https://stackoverflow.com/a/30404503/75799

    opened by iBasit 26
  • Add parameters in fixtures files

    Add parameters in fixtures files

    This pull request add a new feature: it allows to set parameters in fixtures files that will be replaced by there values by a new processor method.

    A use case can be the following:

    parameters:
        medias_directory: /my/medias/path
    
    Application\Sonata\MediaBundle\Entity\Media:
        media0:
            binaryContent: %medias_directory%/picture1.jpg
    
        media1:
            binaryContent: %medias_directory%/picture2.jpg
    
    Feature 
    opened by sroze 23
  • Multiple method call (adders)

    Multiple method call (adders)

    Hi !

    Is there a way to properly call multiple times a method, like an adder method for instance ?

    For instance, the snippet below won't work, because you can't use the same key multiple times in yaml:

    Catalog\Product\Product:
        foo:
           # [...]
            addImage: ['foo-image', 0]
            addImage: ['bar-image', 1]
    

    This adder method accepts multiple arguments, which seems to be a problem for the ArrayAdd class, so the snippet below won't work either:

    Catalog\Product\Product:
        foo:
           # [...]
            images: 
                - ['foo-image', 0]
                - ['bar-image', 1]
    

    Missing argument 2 for Catalog\Product\Product::addImage(), called in [...]/vendor/nelmio/alice/src/Nelmio/Alice/Instances/Populator/Methods/ArrayAdd.php on line 48 and defined

    Is there a simple solution to this ?

    Feature 
    opened by ogizanagi 21
  • Version 2.2 fails loading fixtures

    Version 2.2 fails loading fixtures

    After recent update to 2.2 version i've got this:

    [Hautelook\AliceBundle\Alice\DataFixtures\LoadingLimitException]
    Loading files limit of 50 reached. Could not load the following files /code/src/AppBundle/DataFixtures/ORM/changelogs.yml:

    • Entity with ID @user-1 and class Mailer\AuthBundle\Entity\User not found

    And the same for every fixtures file, where references are present.

    Version 2.1.4 works fine. Has anyone faced this problem too?

    Bug 
    opened by overgapo 20
  • support for private constructors

    support for private constructors

    If entity has a private constructor without arguments create instance without constructor, if it has mandatory arguments throws an exception if explicit construct has been called. Tests covering those cases included, rectified some typos related to faker library too.

    Feature 
    opened by Markcial 20
  • randomElement

    randomElement

    Hi,

    I'm using the latest version of Alice (master branch) and have an issue with the randomElement method.

    Test\Entity:
      entity{1..20}:
        some_field: <randomElement(['some value', 'some other value'])>
    

    I get this error:

    Uncaught Nelmio\Alice\Exception\FixtureBuilder\ExpressionLanguage\LexException: Could not lex the value "['some value'". in /path/to/vendor/nelmio/alice/src/Exception/FixtureBuilder/ExpressionLanguage/LexException.php:25
    

    Am I missing something in array syntax or is it a confirmed bug?

    Bug 
    opened by nlemoine 18
  • v3 - HTML code in fixtures

    v3 - HTML code in fixtures

    Hi, Is there a way to allow HTML in fixtures (or disable the lexer for certain fixtures)? On my first attempt I got the error: PHP Fatal error: Uncaught Nelmio\Alice\Exception\FixtureBuilder\ExpressionLanguage\LexException: Could not lex the value... Then on a simplified test case I got the error:

    PHP Fatal error:  Uncaught InvalidArgumentException: Invalid token "&lt;div&gt;test&lt;/div&gt;" found. in /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php:100
    Stack trace:
    # 0 /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php(76): Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\SubPatternsLexer->lexFragment(Object(Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\ReferenceLexer), '&lt;div&gt;test&lt;/div&gt;')
    # 1 /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php(52): Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\SubPatternsLexer->lex('&lt;div&gt;test&lt;/div&gt;')
    # 2 /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/LexerRegistry.php(45): Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\FunctionLexer->lex('&lt;div&gt;test&lt;/div&gt;')
    # 3 /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php(50): Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\Lexer in /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php on line 100
    > 
    > Fatal error: Uncaught InvalidArgumentException: Invalid token "&lt;div&gt;test&lt;/div&gt;" found. in /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php on line 100
    > InvalidArgumentException: Invalid token "&lt;div&gt;test&lt;/div&gt;" found. in /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php on line 100
    > Call Stack:
    >     0.0004     369992   1. {main}() myFile.php:0
    >     3.2295   11068000   2. Fidry\AliceDataFixtures\Loader\SimpleFileLoader->load() myFile.php:42
    >    69.4117   23879752   3. Nelmio\Alice\Loader\NativeLoader->loadFile() /var/www/project/vendor/theofidry/alice-data-fixtures/src/Loader/SimpleFileLoader.php:48
    >    69.4117   23879752   4. Nelmio\Alice\Loader\SimpleFileLoader->loadFile() /var/www/project/vendor/nelmio/alice/src/Loader/NativeLoader.php:217
    >    69.4418   26515240   5. Nelmio\Alice\Loader\SimpleDataLoader->loadData() /var/www/project/vendor/nelmio/alice/src/Loader/SimpleFileLoader.php:48
    >    69.4418   26515240   6. Nelmio\Alice\FixtureBuilder\SimpleBuilder->build() /var/www/project/vendor/nelmio/alice/src/Loader/SimpleDataLoader.php:46
    >    69.4418   26515240   7. Nelmio\Alice\FixtureBuilder\Denormalizer\SimpleDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/SimpleBuilder.php:39
    >    69.4418   26515728   8. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SimpleFixtureBagDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/SimpleDenormalizer.php:46
    >    69.4418   26515864   9. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\FixtureDenormalizerRegistry->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SimpleFixtureBagDenormalizer.php:63
    >    69.4418   26515864  10. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\Chainable\SimpleDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/FixtureDenormalizerRegistry.php:67
    >    69.4418   26516264  11. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\SimpleSpecificationsDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/Chainable/SimpleDenormalizer.php:81
    >    69.4418   26516376  12. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\SimpleSpecificationsDenormalizer->denormalizeProperty() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php:73
    >    69.4418   26516456  13. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Property\SimplePropertyDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/SimpleSpecificationsDenormalizer.php:103
    >    69.4418   26516456  14. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\UniqueValueDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Property/SimplePropertyDenormalizer.php:40
    >    69.4419   26516456  15. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\SimpleValueDenormalizer->denormalize() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/UniqueValueDenormalizer.php:43
    >    69.4419   26516456  16. Nelmio\Alice\FixtureBuilder\Denormalizer\Fixture\SpecificationBagDenormalizer\Value\SimpleValueDenormalizer->parseValue() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php:44
    >    69.4419   26516456  17. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\FunctionFixtureReferenceParser->parse() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/Denormalizer/Fixture/SpecificationBagDenormalizer/Value/SimpleValueDenormalizer.php:68
    >    69.4419   26516456  18. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\StringMergerParser->parse() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/FunctionFixtureReferenceParser.php:43
    >    69.4419   26516456  19. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Parser\SimpleParser->parse() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/StringMergerParser.php:40
    >    69.4419   26516456  20. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\LexerRegistry->lex() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Parser/SimpleParser.php:50
    >    69.4420   26547672  21. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\FunctionLexer->lex() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/LexerRegistry.php:45
    >    69.4420   26547712  22. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\SubPatternsLexer->lex() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/FunctionLexer.php:52
    >    69.4420   26547808  23. Nelmio\Alice\FixtureBuilder\ExpressionLanguage\Lexer\SubPatternsLexer->lexFragment() /var/www/project/vendor/nelmio/alice/src/FixtureBuilder/ExpressionLanguage/Lexer/SubPatternsLexer.php:76
    

    Thanks, Joe

    Feature 
    opened by mcjwb 17
  • [Needs help] Replace in-house lexer by HoaCompiler

    [Needs help] Replace in-house lexer by HoaCompiler

    Note: this message has been edited to avoid the read of the long discussion of here and the original issue (#601).

    Alice ships with an Expression Language, which allows to interpret values such as @user* or <current()>. This is currently done by an in-house Expression Language which uses a Lexer to tokenize the string input and then a Parser which go through those tokens to transform it in an understandable expression. For example:

    input: '@user*'

    tokens returned by the Lexer:

    [
       new Token('@user*', new TokenType(TokenType::WILDCARD_REFERENCE_TYPE)),
    ]
    

    value returned by the Parser:

    FixtureMatchReferenceValue::createWildcardReference('user')
    

    As explained in greater details here, the fixtures are first build into an understandable structure of objects and then they are evaluated to generate the object we wants.

    The plan now is to replace the in-house lexer with HoaCompiler. The current one relies on regexes and different pass to try to tokenize the input and then the parser trying to create objects from it. HoaCompiler however works with a better structure: a "grammar" which is a set of rules on how to parse strings is created and return a list of nodes from it. That approach is way more robust and would allow to avoid a lot of edge cases where regexes are just not the tool for the job.

    Implementation wise it's not all too complex. Right now most of the Expression Language is tagged as internal so we can afford BC breaks on that part of the library which gives enough freedom to do that work without the need of another major release.

    The current PR provides a start of implementation. The major work to do is to write the grammar which @Hywan already started to match our needs. Once done we can then update the Parser to process those Node objects instead of the tokens from the in-house lexer (that part should be relatively easy).

    Most of the rules that the Expression Language implements are documented here besides the tests.

    Needs work Needs help 
    opened by theofidry 16
  • Column 'ancestor' cannot be null

    Column 'ancestor' cannot be null

    Hello , I am having problem setting up alice for entities with parent and childrens.

    productCategoryParent_{1..3}:
          name: productCategory_parent_<current()>
          createdAt: <datetimeBetween('-5 days', 'now')>
          updatedAt: <datetimeBetween('-5 days', 'now')>
    
    productCategory_{1..30}:
          name: productCategory_<current()>
          parent: '@productCategoryParent_*'
          createdAt: <datetimeBetween('-5 days', 'now')>
          updatedAt: <datetimeBetween('-5 days', 'now')>
    

    When I run the fixture I get SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'ancestor' cannot be null

    In my orm.xml file I have this:

    <many-to-one field="parent" target-entity="ProductCategory" inversed-by="children">
                <join-column name="parent_id" referenced-column-name="id" nullable="true" />
                <gedmo:tree-parent />
            </many-to-one>
            <one-to-many field="children" target-entity="ProductCategory" mapped-by="parent" />
    
    Bug 
    opened by KarolosLykos 15
  • ReflectionPropertyAccessor can access protected but not private properties of an abstract class

    ReflectionPropertyAccessor can access protected but not private properties of an abstract class

    Title is self explanatory. I get the exception Could not hydrate the property "latitude" of the object "TestGeographicLocation" (class: Location\TestGeographicLocation). if trying to hyrdate private properties but it works when using protected/public properties.

    I am using a Loader that extends from NativeLoader so that it uses the ReflectionPropertyAccessor:

    class ReflectionLoader extends NativeLoader
    {
        protected function createPropertyAccessor(): PropertyAccessorInterface
        {
            return new ReflectionPropertyAccessor(parent::createPropertyAccessor());
        }
    }
    

    And the class looks like:

    abstract class GeographicLocation
    {
        private $latitude;
        private $longitude;
    
        public function __construct($latitude, $longitude)
        {
            $this->latitude = $latitude;
            $this->longitude = $longitude;
        }
    }
    

    And a concrete class exmaple:

    class TestGeographicLocation extends GeographicLocation
    {
    }
    

    It only happens with children of abstract classes I believe but it was working in Alice 2.x so the reflection property accessor may need updating to support this like it used to be supported, not sure.

    Bug Has PR 
    opened by jeremy-smith-maco 15
  • Assign entity trough reference parameter

    Assign entity trough reference parameter

    Hello,

    I have three Entities, and one requires the other. I.e. User has many Subscribers which can be part of many Segments.

    With regular Alice logic, I can assign any amount of random Subscribers to Segments, but I want to get them from the User, because in each Segment there can only be Subscribers belonging to Users.

    So my attempt was like so:

    App\Entity\Segment:
      segment{1..25}:
        user: '@user_*'
        name: '<word()>'
        subscriber: @user_*->subscribers
    

    But of course @user_*->subscribers is an instance of Collection, and Alice tries to use the addSubscriber method, which then logically fails.

    I also tried to create a addSubscriberCollection method and use __calls function, but it seems the Segment-Logic is ran before Subscribers are even created, which of course is not ideal, because now Subscribers aren't existing.

    App\Entity\Segment:
      segment_{1..25}:
        user: '@user_*'
        name: '<word()>'
        __calls:
          - addSubscriberCollection:
              collection: '@user_*->subscribers'
    

    How could i possible chain the Fixtures in the correct order? The upper attempt seems to work, but it also seems that the provided Collection is still empty during that time. What to do?

    Maybe, it would even be possible to add a parameter that will specify in which order fixtures are being loaded to be more precise here if desired.

    opened by nopenopenope 1
  • Can't access nested reference property

    Can't access nested reference property

    The second however should work, but maybe @self->city->postalCodes will do?

    Originally posted by @theofidry in https://github.com/nelmio/alice/issues/1019#issuecomment-678705589

    I believe @self->city->postalCodes is a good solution, but it doesn't appear to work. Config is below and error output below that. Using hautelook/alice-bundle 2.11.0, nelmio/alice v3.11.0, and theofidry/alice-data-fixtures 1.6.0. As a workaround, I added method VendorUser::getOrganizationsTenant() which works, however, @self->organization->tenant is nicer.

    App\Entity\Organization\Tenant:
        tenant_organization_{1..5}:
            __factory: { 'App\Entity\Organization\Tenant::create': [] }
            name: <company()>
    
    App\Entity\Organization\Vendor:
        vendor_organization_{1..5}:
            name: <company()>
            tenant: '@tenant_organization_*'
    
    App\Entity\User\VendorUser:
        vendor_user_{1..15}:
            organization: '@vendor_organization_*'
            tenant: '@self->organization->tenant'
            #tenant: '@self->organization->getTenant()'
            #tenant: '@self->organizationsTenant'
            firstName: '<firstName()>'
            lastName: '<lastName()>'
            username: '<username()>'
            plainPassword: 'changeMe'
            jobTitle: '<jobTitle()>'
            email: '<email()>'
    
    In TolerantFixtureDenormalizer.php line 62:
    
      An error occurred while denormalizing the fixture "vendor_user_{1..15}" (App\Entity\User\VendorUser): Could not parse the token "@self->organization->tenant" (type: PROPERTY_REFERENCE_TYPE).
    
    
    In ExpressionLanguageExceptionFactory.php line 47:
    
      Could not parse the token "@self->organization->tenant" (type: PROPERTY_REFERENCE_TYPE).
    
    
    hautelook:fixtures:load [-b|--bundle [BUNDLE]] [--no-bundles] [-m|--manager MANAGER] [--append] [--shard SHARD] [--purge-with-truncate]
    
    Bug Lexer 
    opened by NotionCommotion 0
  • Does nelmio/alice work for multi database fixtures ?

    Does nelmio/alice work for multi database fixtures ?

    Hi there,

    My project use 3 databases, is it possible to use this bundle with that contraint ? I see in command i can set --manager, witch will be great to target wanted database (I have 1 em by database) but I'm confuse with term bundle witch for me is for very old symfony. Can I config or have command option to told alice to load target subfolder of my fixtures folder with this manager and do it for the 3 db ?

    Thx in advance

    opened by Kleinast 2
  • Referencing literal self variables

    Referencing literal self variables

    This code works:

      teacher_community_2:
        __factory:
          from:
            id: ~
            forename: 'Joshua'
            surname: '<lastName()>'
            displayName: 'Dr. $surname'
    

    But this one doesn't:

      teacher_community_2:
        __factory:
          from:
            id: ~
            forename: 'Joshua'
            surname: 'Potato'
            displayName: 'Dr. $surname'
    

    It throws:

    In UnresolvableValueExceptionFactory.php line 77:
                                             
      Could not find a variable "$surname".  
    

    Apparently, the own variables are only available if they come from a Faker source; but not if they are defined as a literal.

    @self->surname does not work either, since it throws:

    In ObjectNotFoundExceptionFactory.php line 23:
                                                                                                
      Could not find the object "teacher_community_2" of the class "Teacher".  
    

    Is this a bug or am I missing something in the documentation?

    Bug 
    opened by xDaizu 1
  • Error on a property that does not exist

    Error on a property that does not exist

    I have a bound problem on a field that does not map but does not exist. It detects a "uid" but it is not present in the model. Any ideas where this could come from?

    Yaml fixture :

    App\Fixture\Model\ExamLocalData:
        exam-local-1:
            examDbId: <examDbId('1.2.840.113619.2.65.5.52240041440.54937.15115710984.6')>
            hostDbId: <hostDbId('WS-NEWYORK')>
            examLocalSize: 256
            examLocalNumSeries: 1
            examLocalLastModified: <dateTimeImmutableFromFormat('1970-01-01 00:00:00', 'Y-m-d H:i:s')>
            examLocalDateCreated: <dateTimeImmutableFromFormat('1970-01-01 00:00:00', 'Y-m-d H:i:s')>
            examLocalNumFiles: 10
            examLocalLastIndexed: <dateTimeImmutableFromFormat('1986-01-01 00:00:00', 'Y-m-d H:i:s')>
            examLocalLastQueried: <dateTimeImmutableFromFormat('1988-01-01 00:00:00', 'Y-m-d H:i:s')>
            examLocalCurrent: 0
    
    

    PHP model :

    class ExamLocalData
    {
        private ?int $examDbId = null;
        private ?int $hostDbId = null;
        private ?int $examLocalSize = null;
        private ?int $examLocalNumSeries = null;
        private ?\DateTimeInterface $examLocalLastModified = null;
        private ?\DateTimeInterface $examLocalDateCreated = null;
        private ?int $examLocalNumFiles = null;
        private ?\DateTimeInterface $examLocalLastIndexed = null;
        private ?\DateTimeInterface $examLocalLastQueried = null;
        private ?bool $examLocalCurrent = null;
    
        public function setExamDbId(int $id)
        {
            $this->examDbId = $id;
        }
    
        public function getExamDbId(): int
        {
            return $this->examDbId; $objectSet = $this->aliceFilesLoader->loadFiles(
                [sprintf('%s/alice/%s', $this->fixtureDirectory, $fixtureFilename)]
            );
    
            $localDataCount = 0;
            foreach ($objectSet->getObjects() as $data) {
                $this->insertExamLocalData($data);
                ++$localDataCount;
            }
        }
    
        public function setHostDbId(int $id)
        {
            $this->hostDbId = $id;
        }
    
        public function getHostDbId(): int
        {
            return $this->hostDbId;
        }
    
        public function setExamLocalSize(int $size)
        {
            $this->examLocalSize = $size;
        }
    
        public function getExamLocalSize(): int
        {
            return $this->examLocalSize;
        }
    
        public function setExamLocalNumSeries(int $num)
        {
            $this->examLocalNumSeries = $num;
        }
    
        public function getExamLocalNumSeries(): int
        {
            return $this->examLocalNumSeries;
        }
    
        public function setExamLocalNumFiles(int $num)
        {
            $this->examLocalNumFiles = $num;
        }
    
        public function getExamLocalNumFiles(): int
        {
            return $this->examLocalNumFiles;
        }
    
        public function setExamLocalLastModified(\DateTimeInterface $date)
        {
            $this->examLocalLastModified = $date;
        }
    
        public function getExamLocalLastModified(): \DateTimeInterface
        {
            return $this->examLocalLastModified;
        }
    
        public function setExamLocalDateCreated(\DateTimeInterface $date)
        {
            $this->examLocalDateCreated = $date;
        }
    
        public function getExamLocalDateCreated(): \DateTimeInterface
        {
            return $this->examLocalDateCreated;
        }
    
        public function setExamLocalLastIndexed(\DateTimeInterface $date)
        {
            $this->examLocalLastIndexed = $date;
        }
    
        public function getExamLocalLastIndexed(): \DateTimeInterface
        {
            return $this->examLocalLastIndexed;
        }
    
        public function setExamLocalLastQueried(\DateTimeInterface $date)
        {
            $this->examLocalLastQueried = $date;
        }
    
        public function getExamLocalLastQueried(): \DateTimeInterface
        {
            return $this->examLocalLastQueried;
        }
    
        public function setExamLocalCurrent(bool $current)
        {
            $this->examLocalCurrent = $current;
        }
    
        public function getExamLocalCurrent(): bool
        {
            return $this->examLocalCurrent;
        }
    }
    
    
    

    Data loader :

     $objectSet = $this->aliceFilesLoader->loadFiles(
                [sprintf('%s/alice/%s', $this->fixtureDirectory, $fixtureFilename)]
            );
    
            $localDataCount = 0;
            foreach ($objectSet->getObjects() as $data) {
                $this->insertExamLocalData($data);
                ++$localDataCount;
            }
    
    

    Term error :

    In SimpleObjectGenerator.php line 112:
                                                                                                                                                                          
      An error occurred while generating the fixture "exam-local-1" (App\Fixture\Model\ExamLocalData): Named parameter "uid" does not have a bound value.  
                                                                                                                                                                          
    
    In MissingNamedParameter.php line 17:
                                                          
      Named parameter "uid" does not have a bound value.  
    
    opened by flug 1
  • Converting types

    Converting types

    I'm struggling to find a way to generate a date using dateTimeBetween and convert it to DateTimeImmutable.

    Example configuration:

    App\Entity\Activity:
        activity_{1..50}:
            createdAt: '<dateTimeBetween("-200 days", "now")>'
    

    Using it leads to doctrine error:

    Could not convert PHP value of type DateTime to type datetime_immutable. Expected one of the following types: null, DateTimeImmutable

    I tried to use the following, bit it also didn't work:

    App\Entity\Activity:
        activity_{1..50}:
            createdAt: '<(\DateTimeImmutable::createFromMutable(dateTimeBetween("-200 days", "now")))>'
    

    Throws Call to undefined function dateTimeBetween() error.

    How can I convert DateTime to DateTimeImmutable?

    Bug 
    opened by Zebradil 12
Releases(3.12.1)
  • 3.12.1(Nov 14, 2022)

  • 3.12.0(Oct 2, 2022)

    Features

    • Add support for enum in symfony property accessor hydrator (#1118)

    Misc

    • Fix PHPUnit configuration (#1119)
    • Fix CS (#1120)
    • Rework the Makefile (#1121)
    • Fix CI PHPStan analysis (#1122)
    • Fix iterator return types (#1123)
    Source code(tar.gz)
    Source code(zip)
  • v3.11.0(Jul 3, 2022)

    Features

    • Add support for newlines in identity() (#1104)
    • Bump dependencies (#1111)
    • Remove support for PHP 8.0
    • Remove support for Symfony 4.4
    Source code(tar.gz)
    Source code(zip)
  • v3.10.0(Dec 10, 2021)

  • v3.9.0(Oct 12, 2021)

    Features

    • Add PHP 8.1 support (#1091)
    • Drop support for PHP 7.3 (#1093)
    • Drop support for Symfony 2.8 & 3.4 components (#1093)
    • Drop support for Symfony 3.4, 4.x except 4.4 (LTS), 5.x except 5.3 (current stable) (#1093)

    Bugfixes

    • Fix reference range wildcard order (#1081)
    Source code(tar.gz)
    Source code(zip)
  • v3.8.2(Feb 27, 2021)

  • v3.8.1(Feb 23, 2021)

  • v3.8.0(Jan 13, 2021)

    Features

    • Add support for PHP 8 (#1064)

    Misc

    • Migrate to GitHub Actions (#1069)
    • Add default value to $previous (#1068)
    • Update Code Style (#1070)
    • Run in GitHub Actions PHPStan (#1071)

    Doc

    • Missing autowire parameter (#1060)
    • Fix links to Faker (#1061, #1072)
    Source code(tar.gz)
    Source code(zip)
  • v2.3.6(Jan 6, 2021)

  • 3.7.4(Nov 4, 2020)

  • 3.7.3(Nov 1, 2020)

  • 3.7.2(Oct 27, 2020)

  • 3.7.1(Jun 3, 2020)

  • v3.7.0(May 16, 2020)

    Features

    • Better parsing of numeric, boolean and null values for function arguments (#1030)
    • Add named parameters support (#1026)

    Misc

    • Remove unused variables $stringFlag (#1027)
    • Maintenance PR (#1032)
    • Upgrade PHPStan (#1033)
    • Upgrade to Infection 0.16 (#1034)
    Source code(tar.gz)
    Source code(zip)
  • v3.6.0(Mar 8, 2020)

    Features

    • Add support for sebastian/comparator 4 (#1024)

    Misc

    • Make testsuite compatible with PHPUnit 8 (#1023)
    • Update the list of PHP versions on CI (#1021)
    Source code(tar.gz)
    Source code(zip)
  • v3.5.8(Dec 4, 2019)

    Bugfixes

    • Allow Symfony 5 support (#1008)

    Misc

    • Upgrade phpstan to v0.11 (#977)
    • Exclude some folders from downloading into vendor with Composer (#1000)
    • Fixed example for evaluated parameters (#1001)
    • Fix an example result (#1007)
    Source code(tar.gz)
    Source code(zip)
  • v3.5.7(May 5, 2019)

  • v3.5.6(Apr 2, 2019)

  • v3.5.5(Mar 14, 2019)

    Bugfixes

    • Fix lexer on long arguments (#980)
    • Add inheritance support to ReflectionPropertyAccessor (#978)
    • Fix reference range flags usage with templates (#979)
    Source code(tar.gz)
    Source code(zip)
  • v3.5.4(Feb 28, 2019)

  • v3.5.3(Dec 22, 2018)

  • v3.5.2(Oct 21, 2018)

  • v3.5.1(Sep 27, 2018)

  • v3.5.0(Sep 1, 2018)

    Features

    • Add more context on failure (#943)
    • Parse tokens as regular strings when unrecognised (#946)

    Bugfixes

    • Fix comparison of objects (#950)

    Misc

    • Mention the hardening of extended fixtures declarations (#944)
    • Add doc regarding extending non-template fixtures & fix the include order (#945)
    • Add missing note in the upgrade guide (#949)
    Source code(tar.gz)
    Source code(zip)
  • v3.4.1(Jun 17, 2018)

  • v3.4.0(May 29, 2018)

    Features

    • Add support for steps with ranges (#539)
    • Add JSON Parser (#919)

    Bugfixes

    • Fix property reference usage with a function call (#926)
    • Do not use minor version for branch alias (#928)
    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(Apr 7, 2018)

  • v2.3.5(Apr 7, 2018)

  • v3.2.2(Mar 17, 2018)

    Bugfixes

    • Throw a friendly error when invalid argument is given (#896)
    • Fix usage of non string unresolvable values (#898)
    • Fix valid circular reference (#900)
    • Fix usage of functions in reference names (#901)
    Source code(tar.gz)
    Source code(zip)
  • v3.2.1(Mar 3, 2018)

Owner
Nelmio
Nelmio
Doctrine-like fixtures integration for Shopware 6.

Shopware 6 Fixtures Did you ever want to create and load Doctrine-like fixtures in your Shopware 6 plugin? Look no further! This plugin provides an ul

Familiy Office 0 Oct 29, 2021
🖥 Build beautiful PHP CLI menus. Simple yet Powerful. Expressive DSL.

Contents Minimum Requirements Installation Upgrading Usage Quick Setup Examples API Appearance Menu Title Colour Width Padding Margin Borders Exit But

PHP School 1.9k Dec 28, 2022
Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

Introduction Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerpl

The Laravel Framework 2.2k Dec 31, 2022
Simple yet expressive schema-based configuration library for PHP apps

league/config helps you define nested configuration arrays with strict schemas and access configuration values with dot notation.

The League of Extraordinary Packages 282 Jan 6, 2023
DinoPHP is a web application framework with expressive.

DinoPHP is a web application framework with expressive. We believe development must be an enjoyable and creative experience. DinoPHP takes the pain out of development by easing common tasks used in many web projects

DinoPHP 23 Dec 14, 2022
Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

Introduction Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services. It handles almost all of the boilerpl

The Laravel Framework 2.2k Jan 4, 2023
Laravel Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

Introduction Laravel Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services. It handles almost all of the b

The Laravel Framework 189 Jan 5, 2023
Unleash the expressive power of the natural language in your Laravel application.

jrmajor/laravel-fluent Unleash the expressive power of the natural language in your Laravel application. Read the Fluent Syntax Guide in order to lear

Jeremiasz Major 17 Dec 17, 2022
The package provides an expressive "fluent" way to define model attributes.

The package provides an expressive "fluent" way to define model attributes. It automatically builds casts at the runtime and adds a native autocompletion to the models' properties.

Boris Lepikhin 506 Dec 28, 2022
Kiaan PHP is a web application framework with expressive, elegant syntax.

About Kiaan framework Kiaan is a web application framework for PHP. Kiaan is easy, flexible and professional. Documentation You can learn kiaan with t

Kiaan 30 Oct 17, 2022
InfyOm Laravel Generator - API, Scaffold, Tests, CRUD Laravel Generator

InfyOm Laravel Generator Generate Admin Panels CRUDs and APIs in Minutes with tons of other features and customizations with 3 different themes. Read

InfyOmLabs (InfyOm Technologies) 3.5k Jan 1, 2023
Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless development of your applications.

Laravel CRUD Generator This Generator package provides various generators like CRUD, API, Controller, Model, Migration, View for your painless develop

AppzCoder 1.3k Jan 2, 2023
Laravel Design Pattern Generator (api generator)

Laravel Design Pattern Generator (api generator) you can create your restful api easily by using this library and you can filter, sort and include elo

HusseinAlaa 2 Sep 25, 2022
One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP

otp-thing One time password generator, validator, and qrcode generator that has no web dependencies (self-contained) in PHP Introduction This started

Daniel Krusky 25 Apr 29, 2022
This bundle provides new generator command line tools for doctrine generator.

GenBundle This bundle provides new generator command line tools for doctrine generator, extending SensioGeneratorBundle. php bin/console gen:generate:

Koldo Picaza 5 Sep 6, 2016
A PHP project/micro-package generator for PDS compliant projects or micro-packages.

Construct A PHP project/micro-package generator for PDS compliant projects or micro-packages. Installation Construct should be installed globally thro

Jonathan Torres 263 Sep 28, 2022
CRUDlex is an easy to use CRUD generator for Symfony 4 and Silex 2 which is great for auto generated admin pages

CRUDlex CRUDlex is an easy to use, well documented and tested CRUD generator for Symfony 4 and Silex 2. It is very useful to generate admin pages for

Philip 108 Jun 30, 2022
Simple static Composer repository generator - For a full private Composer repo use Private Packagist

Satis Simple static Composer repository generator. Run from source Satis requires a recent PHP version, it does not run with unsupported PHP versions.

Composer 2.9k Jan 3, 2023
Daux.io is an documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly. It helps you create great looking documentation in a developer friendly way.

Daux.io - Deprecation Notice This repository is deprecated! Daux.io has been moved to an organization, to guarantee future development and support. So

Justin Walsh 4.6k Dec 16, 2022
Documentation Generator for PHP

phpDocumentor What is phpDocumentor? phpDocumentor is an application that is capable of analyzing your PHP source code and DocBlock comments to genera

phpDocumentor 3.7k Dec 28, 2022