Giter Site home page Giter Site logo

khepinyamlfixturesbundle's Issues

Add embedded fixtures

Sometimes it doesnt make sense or makes things hard to understand to have fixtures separated across many different files. The goal here is to allow doing something like this:

class: Khepin\My\Bundle\Entity\Car
fixtures:
    flying_car: 
        model: xwing            #######
        power: 1000             # These are standard attributes
        max_speed: lightspeed   #######
        passengers:                 ##########
            passenger_1:            # A collection of fixtures
                name: Luke          # defined directly in the same
            passenger_2:            # fixture
                name: Lea           ##########
        driver:                     ##########
            name: Obiwan Kenobi     # A single embedded fixture

Debug

Even when the import was not done successfully the script still says "done", can we print out some debug info?

Warning: Illegal string offset 'model' in v.1.0.0 when loading fixtures

Hi! I just tried to use this bundle in my project, and found this error:

$ console khepin:yamlfixtures:load

[Symfony\Component\Debug\Exception\ContextErrorException] Warning: Illegal string offset 'model'

Exception trace: () at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:112 Symfony\Component\Debug\ErrorHandler->handleError() at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:112 Khepin\YamlFixturesBundle\Loader\YamlLoader->loadFixtures() at /var/www/my_app/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Command/FixturesLoadCommand.php:66 ...

I have investigated what's the problem, and found a weird place in vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Loader/YamlLoader.php:107

$fixture_data = Yaml::parse($file);

After I changed it to

$fixture_data = Yaml::parse(file_get_contents($file));

it worked as expected.

Is this some kind of mistake, or is it just caused by different versions of Yaml component - anyways it's more clear to pass the file data than file name. Could You fix it please? I have found it in both 1.0.0 and 0.8.1 versions, so my pull request is not the best way to do it for all versions.

Thank You!

Posibility to add dynamic datime objects

Often the objects in the database need to be up to date when the fixtures are loaded.
Say we have a project in which we are doing some statistics based on last month activity.
In a large project, that lasts more than 1 month at one time the fixtures will be outdated and the statistics won't show any relevant data and this means that the fixtures have to be updated every week.
In order to avoid this it would be nice if in the fixtures we could have dynamic dates based on today: eg. -5 days, -10 days, -1 month

Do you think it's possible?

Update the doc

Hi, pls, update the doc, e.g. Mongo embed many works fine :) can be showstopper for someone when the doc is not up to date...

createObject() missing from YamlAclFixture

Just updated my symfony project and when I run 'php app/console khepin:yamlfixtures:load dev' I get:

Fatal error: Class Khepin\YamlFixturesBundle\Fixture\YamlAclFixture contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Khepin\YamlFixturesBundle\Fixture\AbstractFixture::createObject) in /symfony2/surpme/vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Fixture/YamlAclFixture.php on line 31

And it seems that createObject() indeed is missing from YamlAclFixture. Also load() in YamlAclFixture is incompatible with the one in AbstractFixture.

balazs

Problem with embedone document in a fixture odm

model: Acme\AddressBundle\Document\Address
persistence: mongodb
fixtures:
Address1:
street: carnevale
city: napoli
province: napoli
zip: 80100

model: Acme\UserBundle\Document\User
persistence: mongodb
fixtures:
User1:
firstname: peppe
lastname: peppuzzo
address:
address: Address1

/* @mongodb\EmbedOne(targetDocument="Acme\AddressBundle\Document\Address")

  • @Assert\Type(type="Acme\AddressBundle\Document\Address", groups={"base_user"})
    • @Assert\Valid() */
      protected $address;

public function setAddress(\Acme\AddressBundle\Document\Address $address)
{
$this->address = $address;
return $this;
}

/** @mongodb\EmbeddedDocument */
class Address {
......................
}

PHP Catchable fatal error: Argument 1 passed to Acme\UserBundle\Document\User::setAddress() must be an instance of Acme\AddressBundle\Document\Address, array given, called in /......./vendor/khepin/yaml-fixtures-bundle/Khepin/YamlFixturesBundle/Fixture/MongoYamlFixture.php on line 70 and defined in /....../src/Acme/UserBundle/Document/User.php on line 107

Service calls

Break from issue #23 :

viliam-husar : allow service calls before and after fixtures file is loaded (not after object is persisted)
khepin : service calls: can't remember very precisely how it worked, have to look at it again

Not working on Symfony 3.4 or Symfony 4 due the lack of Bundle

Hello,

With a very simple configuration file...

khepin_yaml_fixtures:
    directory: Resources/fixtures
    resources:
        - App

...it works free of errors on Symfony 2.8, however if I upgrade to Symfony 3.4 (clean install) or Symfony 4, then the code is not working with error message:

Bundle "App" does not exist or it is not enabled.
Maybe you forgot to add it in the registerBundles() method of your App\Kernel.php file?

Given new Symfony versions are working without bundles, I am unable to run the commands to include my fixtures on dev environment.

Some help might be appreciated.

Best,

Support for Entity constructor parameters?

I did not find any mention about how to pass parameters to Entity's constructor (in order to avoid getter/setter abuse).

Is this possible without extra service calls?

call to undefined method Symfony\Bundle\DoctrineBundle\Registry::getManager()

Hi,

I'm trying to use your bundle to load some fixtures but I run on this error when I use the load command.
I presume it happens because of my bundles versions or my symfony version but I haven't found wich version to use for your bundle.

I use Symfony 2.0.15 et have set your bundle this way on my deps :

KhepinYamlFixturesBundle]
git=https://github.com/khepin/KhepinYamlFixturesBundle.git
target=/bundles/Khepin/YamlFixturesBundle
version=origin/2.0

Is it wrong? Do I absolutely need Symfony 2.1 ?

Thanks

foreign key name lost after a service call

Hi,

When using service call to persist data (FOSUser entities), the name of each fixture, which is used in relations on other entities, seems to be lost.

Example:

The CompanyUserBundle extends FOS User, so does the entity.

model: Company\UserBundle\Entity\User
persistence: orm
service_calls:
    service_1:
        service: fos_user.user_manager
        method: updateUser
fixtures:
    admin:
        firstname: Kevin
        lastname: John
        username: admin
        plain_password: passssssss
        email: [email protected]
        enabled: 1
        locked: 0
        expired: 0
        roles: []

Now, i'm supposed to use "admin" as reference in entities in relation with the users:

model: Company\MediaBundle\Entity\Tag
persistence: orm
fixtures:
    tag_1:
        name: "picture"
        description: "Just pictures"
        create_user: admin

But the "admin" key is not converted into the corresponding user by the loader. Instead, it gives setCreateUser() the string "admin". So i obvisously get this Exception in return:

Catchable Fatal Error: Argument 1 passed to Company\MediaBundle\Entity\Tag::setCreateUser() must be an instance of Company\UserBundle\Entity\User, string given, called in ..........\vendor\khepin\yaml-fixtures-bundle\Khepin\YamlFixturesBundle\Fixture\OrmYamlFixture.php on line 40

Is there a way to use references even after a service call? Thank you guys.

Purge with truncate

Hello,

In the Doctrine/DataFixtures bundle is a setting that can be used to truncate the DB tables so when the fixtures are inserted they will have the same ID on them.

I saw that this bundle uses the purger from the DataFixtures, but is there a method in which I can specify to truncate the tables instead of just use DELETE FROM *.

Thanks

Other loaders

Break from issue #23 :

viliam-husar : add other loaders (maybe XML?)
kehpin : Loaders: AWESOME (but we might need a name change for the bundle...)

Cannot install with composer and symfony 2.0

I cannot install the bundle with composer on my Symfony 2.0 project.

khepin/yaml-fixtures-bundle require dev-master of doctrine/doctrine-bundle.
dev-master of doctrine/doctrine-bundle require 2.1.* of symfony/symfony.

2.1.* of symfony/symfony is not compatible with 2.0 of symfony/symfony.

Could you review the composer file ? Maybe, could you use v1.0.0-beta1 of doctrine/doctrine-bundle or make a special version for Symfony 2.0?

My composer.json file:

"require": {
        "php":                            ">=5.3.2",
        "symfony/symfony":                "2.0.13",
        "doctrine/orm":                   "2.1.6",
        "twig/twig":                      "1.8.*",
        "twig/extensions":                "*",
        "swiftmailer/swiftmailer":        "4.1.7",

        "symfony/assetic-bundle":         "2.0.*",
        "sensio/generator-bundle":        "2.0.*",
        "sensio/framework-extra-bundle":  "2.0.*",
        "sensio/distribution-bundle":     "2.0.*",
        "jms/security-extra-bundle":      "1.1.*",

        "behat/behat-bundle":             "1.0.0",
        "behat/mink-bundle":              "dev-master",
        "fabpot/goutte":                  "*",

        "friendsofsymfony/user-bundle":   "1.2.*",
        "khepin/yaml-fixtures-bundle":    "0.5.*",
        "knplabs/knp-menu-bundle":        "1.0.*",
        "mopa/bootstrap-bundle":          "dev-v2.x_sf2.0",
        "twitter/bootstrap":              "2.0.3"
    },

Use tags in fixture files to set the context

Allow the same fixture file to be valid in different contexts. Maybe something like

model: Name\Space\My\Model
tags: [ prod, test, dev ]
fixtures:
    # ...

If no tags are defined then file is always loaded

Bundle maintenance

HI,
I really like your bundle and have some ideas how to improve it.

  • fix coding standards,
  • allow service calls before and after fixtures file is loaded (not after object is persisted)
  • normalize tests,
  • add other loaders (maybe XML?)
  • add configuration option to fixtures file to define which fixtures should be loaded before... (order by filenames is very hard to maintain when there a lot of fixtures).

So, consider this issue as discussion (i couldn't find your email). If you agree I can start to implement them.

installing in Symfony 2.1 generates error: "Your requirements could not be resolved to an installable set of packages."

After successfully installing Symfony 2.1 and doctrine-fixtures-bundle (on windows 7), I run:

              php composer.phar update

It says:

Updating dependencies
Your requirements could not be resolved to an installable set of packages.

Problem 1

- Installation request for khepin/yaml-fixtures-bundle dev-master -> satisfiable by khepin/yaml-fixtures-bundle dev-master.

- Conclusion: don't install doctrine/doctrine-fixtures-bundle v2.1.0-ALPHA

- Conclusion: remove doctrine/doctrine-fixtures-bundle dev-master

- khepin/yaml-fixtures-bundle dev-master requires doctrine/doctrine-fixtures-bundle 2.* -> satisfiable by 
  doctrine/doctrine-fixtures-bundle v2.0.0, doctrine/doctrine-fixtures-bundle v2.0.1, 
  doctrine/doctrine-fixtures-bundle v2.1.0-ALPHA, doctrine/doctrine-fixtures-bundle 2.0.x-dev.

- Can only install one of: doctrine/doctrine-fixtures-bundle dev-master, doctrine/doctrine-fixtures-bundle v2.0.0.

- Can only install one of: doctrine/doctrine-fixtures-bundle dev-master, doctrine/doctrine-fixtures-bundle v2.0.1.

- Can only install one of: doctrine/doctrine-fixtures-bundle dev-master, doctrine/doctrine-fixtures-bundle 2.0.x-dev.

- Installation request for doctrine/doctrine-fixtures-bundle dev-master -> satisfiable by doctrine/doctrine-fixtures-bundle dev-master.

Load fixture files individually

I wonder if it would be possible to load fixtures individually.

Adding a new --fixture option that let you load a single fixture file specified inside config.yml

This could have some benefits:

  • Flexible data population in a very new database
  • Periodic data loads of specific entities, purging the old data and importing newest from the current fixture file (this can be a modified version each time you make the data load).

If you think this could be useful I can start to give it a try.

Coding standards

Break from issue #23 :

viliam-husar : fix coding standards
khepin : CS: sure, would be good

Support for MongoDB

Right now only doctrine ORM is supported. I'd like to add support for MongoDB and possibly CouchDB (but I'm not a user here...).

The setting should probably be set on a fixture file basis rather than a global bundle setting as it is possible to use Mongo && the ORM together in the same project.

Decode characters from fixtures file to database

Hi,

My scenario is a database charset in latin1 and fixtures files in utf8.

In order to convert characters correctly had to do an utf8_decode, as commit below: SHA: 9ad1a87

Do you have any idea to do this in a better and structured manner?

Best regards,
Luís Sousa

Support for application parameters in fixtures

for example:

# app/config/parameters.yml
parameters:
   base_path: web/files

#.../DataFixtures/data.yml
model: Me\MyBundle\Entity\File
fixtures:
  file1:
    src: %base_path%/1.jpg

SELECT * from File
id, src
1, web/files/1.jpg

It could helps for deploy and testing.

Normalize tests

Break from issue #23 :

viliam-husar : normalize tests
khepin : Tests: sure, I love tests!

Allow more complex file ordering

So first I'm certainly not willing to remove the requirement for users to order fixture files by themselves. This was the case in Doctrine1 but it meant a lot of work behind the scenes and I have bad memories of waiting in front of my screen for fixtures to load.

The case for this is the following:

I have 3 entities:

  • BundleA\EntityOne
  • BundleA\EntityTwo
  • BundleB\EntityThree

That need to be loaded in the following order:

  • BundleA\EntityOne
  • BundleB\EntityThree
  • BundleA\EntityTwo

This is currently not possible. And I am still unsure it's a good thing to do. Right now this seems to me like the bundles would need to be refactored in a better way. However if there's a strong case for this I'll see what's possible. This would also mean a much more complex configuration and I'm not really happy about that ;-)

Define YamlLoader class in config.yml ilo hardcoded

Great Bundle! I am using it a lot to setup the base data of the application before populating the database with the data of the symfony1 application.
However, for test purposes, I would like to be in the position to load only a few fixtures,
The first tests should see an empty DB, then loading - test by test - the database from scratch, but test 1 would contain only 1 fixture, test 2 the first 2 or 3 etc. This would require to modify YamlLoader::loadFixtureFiles only.
I would like to create a class to extend YamlLoader and overwrite loadFixtureFiles and/or loadFixtures.
Can you make the bundle flexible enough to load a different class ilo Khepin\YamlFixturesBundle\Loader\YamlLoader to be specified in the config file? (cf FOSUserBundle)

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.