GithubHelp home page GithubHelp logo

bazingafakerbundle's Introduction

BazingaFakerBundle

Build Status

This bundle integrates Faker, a PHP library that generates fake data for you. It provides a command to load random data for your model objects as simple as possible.

Documentation

For documentation, see:

Resources/doc/

Read the documentation

Contributing

See CONTRIBUTING file.

Credits

License

This bundle is released under the MIT license. See the complete license in the bundle:

Resources/meta/LICENSE

bazingafakerbundle's People

Contributors

alister avatar dafish avatar garak avatar gelolabs avatar guilhemn avatar havvg avatar mwadon avatar natebrunette avatar nenadalm avatar pablodip avatar pborreli avatar seldaek avatar sensi avatar thvd avatar willdurand avatar yakobe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bazingafakerbundle's Issues

Delete data before inserting

Hello,

I used to work with Doctrine Fixtures, and by default it deletes datas before insert the new datas. Is this possible with this bundle?

Thank you

Please provide simple documentation on how to use it

Hi,
Could you please send me an example of how can I use this bundle ?
For example I have an Entity Person, which has properties, workPhone and cellPhone
I have this in my config_dev.yml
http://gist.github.com/1675612
This is my entity http://gist.github.com/1675621
I thought I should configure each method for each field in my Entity, but when I removed custom_formatters it almost worked,
it generated lastName and firstName but not the phone numbers, also envelope number was wrong generated
Could you please help me with this ?

How can i change locale

bazinga_faker:
    locale: ru_RU

it doesn't work, it still filled database British symbols...

Many to Many relationships

Hi,
I need to make faker result in my jointure table product_category but it's not an entity, it's just a relation :

manyToMany:
   categories:
      targetEntity: Category
      inversedBy: products
      joinTable:
        name: product_category
        joinColumns:
          product_id:
            referencedColumnName: id
        inverseJoinColumns:
          category_id:
            referencedColumnName: id
            unique: true

how can i do with yaml to fill my jointure table ?

thx a lot !

how call methods which require 2 or more parameters?

calling the official dateTimeBetween method like this:

        MyCompany\MyBundle\Model\Event:
            number:         50
            custom_formatters:
                Title:          { method: null }
                StartDate:      { method: dateTimeBetween, parameters: [ '-1 days', '+1 month' ] }

results in an error:

[ErrorException]
  Warning: strtotime() expects parameter 1 to be string, array given in .\vendor\fzaninotto\faker\src\Faker\Provider\DateTime.php line 82

How to handle different custom formatters for the same table

I would like to generate in the same table two different data sets with different formatter on the same columns

I tried the first idea that came in mind to declare the model twice but the first declaration isn't used.

Is there any way to do such a thing ?

optional not being used correctly

Whenever I tried to implement optional, I always got the fake value. I assume I'm trying to use it right:
foobar: {method: realText, optional: true}

The Faker docs state:
// optional() accepts a weight argument to specify the probability of receiving the default value.
// 0 will always return the default value; 1 will always return the provider. Default weight is 0.5.

and in Factory/FormatterFactory.php, you are incorrectly implementing it as:
$generator = $generator->optional((double) $optional);

producing a value of 1.0 being passed to optional(), which always gives the fake value

So, removing the (double) $optional param makes Faker default to a weight of 0.5.

documentation enhancement proposal

I think that this bundle is great, but I currently use it only in dev or in test environment. I think that this usage is pretty common (I mean, I cannot find any good use case for production).
So, my proposal for a docs improvement is to enforce using this bundle in dev/test env only, just like, for example, SensioGeneratorBundle.
Needed changes are for bundle registering and for config_dev.yml use.
If agreed, I can do a PR.

Performance of big data

I want to insert big data in two tables user -> notifications (about 50k user and 5M notifications). So it is taking very long to be executed. Is it possible to split data insertion ?

Maybe I have to write this in Faker instead of there.

The "faker.populator" service or alias has been removed

Hi,

I just tried to use this bundle in an sf4 project but I get the following error message after following documentation steps.

Am I doing something wrong?

 The "faker.populator" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.

Here is my config

# fconfig/packages/dev/bazinga_faker.yml
bazinga_faker:
    orm: doctrine
    entities:
        App\Entity\Business:
            number: 50

Fake data in Entity with relationships

I has two entities, for example: Country and City. City has relationship with Country (by country_id):

    entities:
       Entity\Country:
            number: 100
            custom_formatters:
                code: { method: countryCode }
                title: { method: country }
       Entity\City:
            number: 20
            custom_formatters:
                country: { method: randomNumber, parameters: [1,2,3,4,5] }

With country or any standalone entity i don't have any problem, all is ok. But how now i can set country_id in City if in City (entity) i have:

    /**
     * Set country
     *
     * @param \Entity\Country $country
     * @return City
     */
    public function setCountry(\Entity\Country $country = null)
    {
        $this->country = $country;

        return $this;
    }

    /**
     * Get country
     *
     * @return \Entity\Country 
     */
    public function getCountry()
    {
        return $this->country;
    }

I try randomNumber or randomElement, but they not work for me like i expected, country_id is NULL after populate City table.

Incorrect class key in services

The following file: https://github.com/willdurand/BazingaFakerBundle/blob/master/Resources/config/services.xml

Line 29.

Reads:

        <service id="Bazinga\Bundle\FakerBundle\Command\PopulateCommand" class="%faker.populate.class%">
            <tag name="console.command" />
        </service>

But should read:

        <service id="Bazinga\Bundle\FakerBundle\Command\PopulateCommand" class="%faker.populate_command.class%">
            <tag name="console.command" />
        </service>

This causes composer require willdurand/faker-bundle:dev-master to fail when installing for Symfony 4.

n:m table data population throw integrity constraint violation

Env = SF2.3 / Propel 1.6.9

schema.xml:

    <table name="follow" isCrossRef="true">
        <behavior name="timestampable" />
        <column name="user_id" type="integer" required="true" primaryKey="true" />
        <column name="debate_id" type="integer" required="true" primaryKey="true" />
        <foreign-key foreignTable="user" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="user_id" foreign="id" />
        </foreign-key>
        <foreign-key foreignTable="debate" onDelete="CASCADE" onUpdate="CASCADE">
            <reference local="debate_id" foreign="id" />
        </foreign-key>
    </table>

I've populated the 2 foreign tables without problem and want some random datas for the crossRef table:

        Acme\Model\Follow:
            number:                     150

The faker:populate try to populate this table with _sometimes_ the 2 same lines and for sure it throws the exception:

[PropelException]                                                                                                                                                     
  Unable to execute INSERT statement [INSERT INTO `follow` (`user_id`, `debate_id`, `created_at`, `updated_at`) VALUES (:p0, :p1, :p2, :p3)] [wrapped: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '73-136' for key 'PRIMARY']  

I've got the same problem with an "equal nest" table/relation.

Thanks.

Tests are broken for me !?

Hi,

I have an error running command line and unit tests :

PHP Fatal error:  Call to a member function parse() on a non-object in /media/OS/mach/vendor/faker/src/Faker/Provider/Address.php on line 91

Have you got any idea ?

Cédric

last faker updates?

Hello,

I've just installed this bundle but it seems that I don't have the last code of the FakeBundle. For example, I've edited the "Image" class code, and don't have the "fullPath" argument described in the FakeBundle documentation.

public static function image($dir, $width = 640, $height = 480, $category = null)

FakeBundle documentation:

/**
 * Image generation provided by LoremPixel (http://lorempixel.com/)
 *
 * @param $dir An absolute path to a local directory
 * @param $width/$height Size (in pixel) of the generated image (defaults to 640x480)
 * @param $category One of 'abstract','animals','business','cats','city','food','nightlife','fashion','people','nature','sports','technics', and 'transport'
 * @param $fullPath Whether to have the full path to the image or just the filename (default true)
 */

Is there something to change in the composer file?

Thanks.

documentation: how to load custom formatters?

i am looking for the best practice on how to add custom formatters to faker in a symfony project with the faker bundle.

also see fzaninotto/Faker#49

for example if i want to add a Provider named FutureDates

<?php

namespace Faker\Provider;

class FutureDates extends \Faker\Provider\Base
{
    /**
    * @example DateTime('2011-09-19 09:24:37')
    * @return \DateTime
    */
    public static function dateTimeNextYear()
    {
        return static::dateTimeBetween("now", "+1 year");
    }

    /**
    * @example DateTime('2011-10-05 12:51:46')
    * @return \DateTime
    */
    public static function dateTimeNextMonth()
    {
        return static::dateTimeBetween("now", "+1 month");
    }
}
  • where to put?
  • how to tell fakerbundle to load and use them?

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.