Giter Site home page Giter Site logo

doctrine / doctrinefixturesbundle Goto Github PK

View Code? Open in Web Editor NEW
2.4K 28.0 201.0 416 KB

Symfony integration for the doctrine/data-fixtures library

License: MIT License

PHP 100.00%
symfony symfony-bundle doctrine-fixtures doctrine fixture-loading fixtures

doctrinefixturesbundle's Introduction

doctrinefixturesbundle's People

Contributors

ajessu avatar alcaeus avatar beberlei avatar bgamrat avatar brikou avatar chris8934 avatar cordoval avatar derrabus avatar fabpot avatar franmomu avatar gajdaw avatar garak avatar greg0ire avatar guilhermeblanco avatar javiereguiluz avatar jean85 avatar jwage avatar lstrojny avatar nicolas-grekas avatar noemiquezada avatar oskarstark avatar philetaylor avatar ruudk avatar sebastianstucke87 avatar simperfit avatar stof avatar taluu avatar thomaslandauer avatar weaverryan avatar xabbuh 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrinefixturesbundle's Issues

Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found

I downloaded the symfony 2.1.6 with composer and DoctrineFixturesBundle with composer update and set in composer.json:
"doctrine/doctrine-fixtures-bundle": "*@dev" (because "dev-master" - doesn't worked).
when i run the php app/console doctrine:fixtures:load i get the fatal error.

I notice that the doctrine folder structure is : doctrine-fixtures-bundle -> Doctrine -> Bundle -> DoctrineFixturesBundle -> DoctrineFixturesBundle.php
if i change the line in the AppKernel.php from this:
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
to this:
new Doctrine\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
I end with an error.
than i notice there is an colsed issue about this so i changed back to :
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
i searched a lot in the web for answer. how can i fix it

Sf 2.1 and composer error when "doctrine/doctrine-fixtures-bundle" is required

Hello all,

I'd like to use DoctrineFixturesBundle with my Sf 2.1 project, but composer gave me error on doctrine doctrine-fixtures-bundle:

#: php composer.phar update doctrine/doctrine-fixtures-bundle --dev
Updating dependencies
Updating dev dependencies
  [InvalidArgumentException]
  Package is not installed: doctrine/doctrine-bundle-9999999-dev

I'm using latest ver of composer.phar and composer.json already includes "doctrine/doctrine-bundle": "dev-master" , so I don't understand what is wrong (everything else works). Is it a composer bug?

Regards,
Antonio.

No license informations

e.g. DoctrineFixturesBundle.php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <[email protected]>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

But no "LICENSE" file in this repository. (Do you tell about "LICENSE" file in Symfony2 repository?)

What's license of this repository? Have all contributors understood about its hidden license?

orderedfixtures being skipped

I have an ordered set of fixtures and am getting missing index errors but unless I'm reading the ouptut wrong it seems like its skipping the fixture that loads the missing index.

$ php app/console doctrine:fixtures:load 
Careful, database will be purged. Do you want to continue Y/N ?y
  > purging database
  > loading [1] Scss\UserBundle\DataFixtures\ORM\LoadUserData
  > loading [3] Scss\GeographyBundle\DataFixtures\ORM\LoadRegionData



  [ErrorException]                                                                                                                                                                      
  Notice: Undefined index: ptc-bsa

LoadUserData is ordered as 1,
LoadOrganizationData is ordered as 2
and LoadRegionData is set for 3
the index ptc-bsa is the only fixture within the LoadOrganizationData file to be loaded.

is this a bug or am i missing something?

add support for yml file fixtures with nelmio/alice

would be cool to support alice (and with it, faker) so that we can just load fixtures from simple files instead of writing code. see https://github.com/nelmio/alice

i can do a PR, but wanted to ask first

  • should i extend doctrine:fixtures:load to support both? or do we rather do a new command, and what should that command be named?
  • i propose to make alice an optional dependency and only load the service if alice is available.

right now i do a pseudo-fixture class that just uses alice.

use Nelmio\Alice\Fixtures;
class LoadPersonData implements FixtureInterface
{

    public function load(ObjectManager $manager)
    {
        Fixtures::load(__DIR__.'/data/person.yml', $manager);
        $manager->flush();
    }
}

[IDEA] add a configuration to define the load paths

What do you think about adding a configuration to specify the paths from where doctrine should load the fixtures?

By now there is the --fixtures option, but is long to type, and in symfony we can rely on the config component.

This is just an idea!...but it's easy to implement....so let me know if I can work on a pr...

class name or namespace probably has a typo

Hi,

I install this bundle but i have such an error:

RuntimeException: The autoloader expected class "Symfony\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle" to be defined in file "/home/platne/sgnx/public_html/app/../vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle/DoctrineFixturesBundle.php". The file was found but the class was not in it, the class name or namespace probably has a typo.

I have been thinking for a while and i am realy stucked and do not know how to avoid that error. I'm usung master versions all my bundles + DoctrineFixturesBundle.php has a class DoctrineFixturesBundle so why an error ?

The autoloader expected class "Doctrine\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle" to be defined ...

in my deps

[DoctrineFixturesBundle]
    git=git://github.com/doctrine/DoctrineFixturesBundle.git
    target=/bundles/Doctrine/Bundle/DoctrineFixturesBundle

in my autoload:

    'Doctrine\\Common\\DataFixtures' => __DIR__.'/../vendor/doctrine-fixtures/lib',

    'Symfony'          => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
    'Sensio'           => __DIR__.'/../vendor/bundles',
    'JMS'              => __DIR__.'/../vendor/bundles',
    'Doctrine\\Bundle' => __DIR__.'/../vendor/bundles',
    'Doctrine\\Common' => __DIR__.'/../vendor/doctrine-common/lib',
    'Doctrine\\DBAL'   => __DIR__.'/../vendor/doctrine-dbal/lib',
    'Doctrine'         => __DIR__.'/../vendor/doctrine/lib',
    'Monolog'          => __DIR__.'/../vendor/monolog/src',
    'Assetic'          => __DIR__.'/../vendor/assetic/src',
    'Metadata'         => __DIR__.'/../vendor/metadata/src',

AppKernel:

            new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
            new Symfony\Bundle\SecurityBundle\SecurityBundle(),
            new Symfony\Bundle\TwigBundle\TwigBundle(),
            new Symfony\Bundle\MonologBundle\MonologBundle(),
            new Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
            new Symfony\Bundle\AsseticBundle\AsseticBundle(),
            new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
            new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
            new JMS\SecurityExtraBundle\JMSSecurityExtraBundle(),

            new Chewbacca\CoreBundle\ChewbaccaCoreBundle(),
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new Acme\Lacroco\ParserBundle\AcmeLacrocoParserBundle(),
            new Chewbacca\StoreBundle\StoreCoreBundle\ChewbaccaStoreCoreBundle(),
            new Acme\Lacroco\StoreBundle\AcmeLacrocoStoreBundle(),
            new Avalanche\Bundle\ImagineBundle\AvalancheImagineBundle(),
            new FOS\UserBundle\FOSUserBundle(),
            new Chewbacca\Backend\CoreBundle\ChewbaccaBackendCoreBundle(),
            new Acme\Lacroco\Backend\StoreBundle\AcmeLacrocoBackendStoreBundle(),

            // Admin Generator
            new Admingenerator\GeneratorBundle\AdmingeneratorGeneratorBundle(),
            new Knp\Bundle\MenuBundle\KnpMenuBundle(),
            new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
            new Doctrine\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle(),
            new JMS\AopBundle\JMSAopBundle(),

when update/install vensodrs get error:

The autoloader expected class "Doctrine\Bundle\DoctrineFixturesBundle\DoctrineFixturesBundle" to be defined in file 
"vendor/bundles/Doctrine/Bundle/DoctrineFixturesBundle/DoctrineFixturesBundle.php". 
The file was found but the class was not in it, the class name or namespace probably has a typo.  

Sharing an ArrayObject or an array between ordered fixtures

I am wondering why it is impossible to share classes (except Entities) between fixtures when using the addReference method of AbstractFixture class.

I am using in a fixture a code like this :

//$themes is an array of Entity
$this->addReference("themes",new \ArrayObject($themes));  

and when I execute the doctrine:fixtures:load command, I am always getting an

[Doctrine\Common\Persistence\Mapping\MappingException] The class 'ArrayObject' was not found in the chain configured namespaces

Your requirements could not be solved to an installable set of packages.

Get the following error:

Your requirements could not be solved to an installable set of packages.

Problem 1
- Installation request for doctrine/doctrine-fixtures-bundle dev-master -> satisfiable by doctrine/doctrine-fixtures-bundle dev-master.
- doctrine/doctrine-fixtures-bundle dev-master requires doctrine/data-fixtures * -> no matching package found.

Potential causes:

when I add

"doctrine/doctrine-fixtures-bundle" : "dev-master"

to my composer file...

full composer file can be found at: http://pastebin.com/QAEkqEgd

Bundle Dependency

Doc's need to be updated to reflect that the DataFixtures Bundle depends on the Doctrine bundle being installed first.
This was discovered using Symfony's standard distribution and adding just:

[doctrine-fixtures]
    git=http://github.com/doctrine/data-fixtures.git

[DoctrineFixturesBundle]
    git=http://github.com/doctrine/DoctrineFixturesBundle.git
    target=/bundles/Doctrine/Bundle/FixturesBundle

to the deps file, when the minimum required is:

[doctrine-fixtures]
    git=http://github.com/doctrine/data-fixtures.git

[DoctrineBundle]
    git=http://github.com/doctrine/DoctrineBundle.git
    target=/bundles/Doctrine/Bundle/DoctrineBundle

[DoctrineFixturesBundle]
    git=http://github.com/doctrine/DoctrineFixturesBundle.git
    target=/bundles/Doctrine/Bundle/FixturesBundle

Remove exception when no fixtures are found (or add an option to suppress this error)

Currently the command throws an exception if there are no exceptions to load. The issue we are having with this is that it causes problems in automated deployment code when we want to always run fixtures. It returns an error status code when there are no fixtures to run.

Having an option to suppress this exception so it doesnt generate an error status code on the command line (and thus potentially halt the calling scripts) would work fine as well and not introduce a potential BC change. I can submit a PR if this solution would be accepted. Option would be called something like

--allow-empty
--suppress-no-fixtures-exception

[Purge] Purging not working correctly with MySQL.

I am using MySql and InnoDB engine. Doctrine generates tables with foreign keys.

While purging a database I am getting the error:

[PDOException]                                                                                                                                                                                                                                         
SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`jobly`.`message`, CONSTRAINT `FK_B6BD307F8829462F` FOREIGN KEY (`message_thread_id`) REFERENCES `message_thread` (`id`))  

That can be avoided by adding SET foreign_key_checks = 0; somewhere.
or there should be a way to inject your own purger to command (like ORMMysqlPurger).

I would really do a PR with the fix but I want to know your thoughts about the best way to handle it.

Fixture Dependency

Instead of using getOrder(), can we not declare which fixture classes the current class depends on?

public function load($manager)
{
   $ob = new Object;
   $ob->setBar($manager->merge($this->getReference('FooBarBundle::bar-1')));
   $ob->setFoo($manager->merge($this->getReference('BarFooBundle::foo-1')));
}

public function getDependencies()
{
    return array(
       'Foo\BarBundle\Fixtures\LoadBarFixtures',
       'Bar\FooBundle\Fixtures\LoadFooFixtures',
    );
}

doctrine:fixtures:load --purge-with-truncate fails

If I run app/console doctrine:fixtures:load --purge-with-truncate I get the error SQLSTATE[42000]: Syntax error or access violation: 1701 Cannot truncate a table referenced in a foreign key constraint

fix to correct github repo

seems like composer.json is out of sync

Problem 1
- Installation request for doctrine/doctrine-fixtures-bundle dev-master -> satisfiable by doctrine/doctrine-fixtures-bundle dev-master.
- doctrine/doctrine-fixtures-bundle dev-master requires doctrine/data-fixtures * -> no matching package found.

Namespace compatibility

HI.

For people who use the old structure, maybe you should add someting in the configuration.

Just change the line

use Doctrine\Bundle\DoctrineBundle\Command\DoctrineCommand;

To

use Symfony\Bundle\DoctrineBundle\Command\DoctrineCommand;

In the file vendor/bundles/Doctrine/Bundle/FixturesBundle/Command

Problem setting fixture references when using ODM

I'm using DoctrineFixturesBundle with the Doctrine ODM. When I try to set a reference in a fixture, I get this error:

Fatal error: Call to undefined method Doctrine\ODM\MongoDB\UnitOfWork::getEntityIdentifier() in /var/www/dev/linx/symfony/vendor/doctrine-fixtures/lib/Doctrine/Common/DataFixtures/ReferenceRepository.php on line 79

The reference repository should call Doctrine\ODM\MongoDB\UnitOfWork::getDocumentIdentifier() when using the ODM.

composer installation

Hi,

when we will add only :

"doctrine/doctrine-fixtures-bundle": "dev-master"

compose will return error like:

Problem 1
- Installation request for doctrine/doctrine-fixtures-bundle dev-master -> satisfiable by doctrine/doctrine-fixtures-bundle[dev-master].
- doctrine/doctrine-fixtures-bundle dev-master requires doctrine/data-fixtures * -> no matching package found.

So, when I added line:

"doctrine/data-fixtures": "dev-master",

before doctrine-fixtures-bundle everything passed without any problems.

I think You should fix documentation because this can help others people.

Regards,
Łukasz

[LoadDataFixturesDoctrineCommand] doctrine:fixtures:load --env=test

Hi,

Usually when we develop we have more than one set of fixtures,
for example, the fixtures are many more on stage than on test
So we created two folder foreach bundle

DataFixtures / test / ORM / ...
DataFixtures / ORM / ... // stage

It would be nice if you could load a set of fixtures
depending from wich environment you select, for example for the 'dev' env.
would be loaded the fixtures in bundleName / DataFixtures / dev / ORM / ...

The solution is easy just add a parameter and add a row on the row number 90.

I could do it, what do you think?

Problem with this bundle [ORM and ODM]

If you would like to use this bundle without ODM installation, you are this problem:

"PHP Fatal error: Class 'Symfony\Bundle\DoctrineMongoDBBundle\Command\DoctrineODMCommand' not found in ..."

Is it possible to split that ?

[RFC] Annotated Fixtures

Wouldn't it be great to use annotations to specify some options? Think about the order or the environment(s), in which the fixture-instance should run.

/**
 * @Fixture("dev", order=100)
 */
class LoadUsers implements FixtureInterface
{
    function load(ObjectManager $manager)
    {
        // some stuff
    }
}

or

/**
 * @Fixture(env={"dev", "prod"})
 * Not giving any order could imply order=0
 */
class LoadUsers implements FixtureInterface
{
    function load(ObjectManager $manager)
    {
        // some stuff
    }
}

As a preview, i implemented the necessary stuff without backward-compability here https://github.com/rejinka/DoctrineFixturesBundle. If everybody is fine with using annotations on fixtures, i would make a Pull-Request and we can then discuss about the implementation and how to fix the backward-compability.

load task not using Entity table name

I got a entity named "order" within my application and cannot use doctrine:fixtures:load as it tries to DELETE FROM order which breaks MySQL. I got the following annotation within the entity, but it doesn't change anything:
@ORM\Table(name="Order")

As a quickfix, I added line 119 in Doctrine\Common\DataFixtures\Purger\ORMPurger:
$tbl = '' . $tbl . '';

It works for me now, but I guess that's not a clean solution.

Time for a stable release?

As Symfony 2.3 SE has minimum stability set to stable this package isn't working. Why not create a stable release? Or at least a new tag (the last one is over a year old).

[Command] Updated from Command->container to ContainerAwareCommand->getContainer()

Updated to the new ContainerAwareCommand class to remove the undefined property error:

Notice: Undefined property: Symfony\Bundle\DoctrineFixturesBundle\Command\LoadDataFixturesDoctrineCommand::$container in /var/www/erc-62.local/vendor/bundles/Symfony/Bundle/DoctrineFixturesBundle/Command/LoadDataFixturesDoctrineCommand.php line 88

purge table with self reference

I have an entity like this:

class FieldType
{

  /**
   * @var integer $id
   *
   * @ORM\Column(name="id", type="integer", nullable=false)
   * @ORM\Id
   * @ORM\GeneratedValue(strategy="IDENTITY")
   * @ORM\OneToMany(targetEntity="FieldType", mappedBy="parentField")
   *
   * @GRID\Column(visible=false, source=true)
   */
  private $id;

  /**
   * @var string $name
   *
   * @Gedmo\Translatable
   * @ORM\Column(name="name", type="string", length=255, nullable=false)
   * @GRID\Column(field="name", visible=true, source=true)
   */
  private $name;

  /**
   * @var FieldType
   *
   * @ORM\ManyToOne(targetEntity="FieldType", cascade={"persist","remove"})
   * @ORM\JoinColumns({
   *   @ORM\JoinColumn(name="parent_field_id", referencedColumnName="id")
   * })
   */
  private $parentField;```
The purge gives me an FK error in both prurge modes.

Should this have been suported?

Debug Output

I am wondering if it's possible to have any Debug Output for the Fixtures Creation. I have pretty huge Fixtures, that will need to load pretty long, so it would be really Comfortable to see any Progress.

Is it possible?

Set custom object ID

Sorry for stupid question, but how can I set ID to some object, like?:

$customerType = new CustomerType();

$customerType
            ->setId(1000)
            ->setIsActive(true);

Loading fixtures destroys index on MongoDB Collections

When loading the Fixtures using MongoDB as storage engine i ran into a nasty problem.. the database get's dropped, indices deleted - and not restored.

php app/console doctrine:mongodb:fixtures:load

purging database
loading ...

This forces you to execute another task manually, to substain data integrity

php app/console doctrine:mongodb:schema:update

Updated indexes for all classes

Wouldn't it make sense to include index generation in the task itself?

Loading References breaks on STI Root

Setup:

EntityA is a root class for a STI setup. In its DiscriminatorMap is has a pointing to itself and b pointing to EntityB. So EntityA is the root but is also a valid entity.

In my Testing setup the ProxyReferenceRepository is used, and it works just fine on the first run, however on the second run (caches not cleared) it breaks with spl_object_hash() expects parameter 1 to be object, null given.

I seem to have tracked it to the fact that a null reference is obtained from the unserialization and then once its passed to the setReference() method it breaks the unitofwork since it just calls spl_object_hash on whatever it gets for isInIdentityMap.

Any ideas on what is wrong here?

Integrity constraint violation when purging database

I get an error when i try to execute doctrine:fixtures:load and the database is purged.

Symfony > doctrine:fixtures:load
Careful, database will be purged. Do you want to continue Y/N ?y
  > purging database

  [Doctrine\DBAL\DBALException]                                                                
  An exception occurred while executing 'DELETE FROM messaging_inbox':                         

  SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row:  
   a foreign key constraint fails (`ruw`.`profile`, CONSTRAINT `FK_8157AA0F18DA89DD` FOREIGN  
   KEY (`inbox_id`) REFERENCES `messaging_inbox` (`id`))                                       

  [PDOException]                                                                               
  SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row:  
   a foreign key constraint fails (`ruw`.`profile`, CONSTRAINT `FK_8157AA0F18DA89DD` FOREIGN  
   KEY (`inbox_id`) REFERENCES `messaging_inbox` (`id`))                                       

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

The command terminated with an error status (1)

I'm using the latest master.

tries to purge readonly entities

I have serveral DoctrineORM entities in readOnly=true mode. When I'm running doctrine:fixtures:load - it tries to delete them.

I think it shouldn't delete/truncate tables which entities ar marked as readonly?

In my case those entities ar mysql views ...

Possibility To Load Without Purging And Without Duplicates

My question is based on this StackOverflow question.

I am not quite sure if that is the right repository for this question, but you will probably tell me if it is not :-)

Currently, it is afaik not possible to load fixtures without purging the database and without having duplicates. Possibilities:

  • php app/console doctrine:fixtures:load → will purge the database
  • php app/console doctrine:fixtures:load --apend → will load all fixtures again, so that we may have duplicate entries (for all fixtures which have already been loaded)
  • php app/console doctrine:fixtures:load --apend --fixtures sth → that does indeed solve the problem manually. But in this case, I have to know exactly which fixtures have already been loaded and which ones I still have to load. That is not really a feasible solution.

Hence, if I am right, there is no suitable solution for the problem. But I think there definitely should be one...

Add option to set purger.

Right now the ORMPurger is hard coded. It would be useful if there was an option in the LoadDataFixturesCommand to set which purger to use.

Referencing same object multiple times before flushing

I just encountered a problem with referencing an object multiple times with different names before flushing. It seems only the first reference I make gets persisted and is available in following fixtures. Here is an example:

public function load(ObjectManager $manager)
{
        $obj = new Obj();
        $obj->setFoo('bar');

        $manager->persist($obj);

        $this->addReference('first-reference', $obj);
        $this->addReference('second-reference', $obj);

        $manager->flush();
}

When referencing "first-reference" in the following fixture I get the persisted object I expect. But if I reference "second-reference" I get an object that is in an unpersisted state. This is problematic if I want to relate the previously persisted object to another object in a following fixture by referencing "second-reference".
If I flush before adding the references, everything works fine. Is it a bug or an intended behaviour?

reset sequence on purge-with-truncate ?

Hi,

With postgresql, I notice that sequences are not reset with purge-with-truncate option.

It could be very usefull when we run tests with fixtures...
Is it plan to next improvement or is there tip to make it ?

thx

[rfc] ability to serialize and dump reference repository.

It is pretty cool to have ability to get an entity in test by it is reference in fixtures. Current solution is to create a command which is copy\past of data:load command and add there reference repository.

Now it is not possible because the reference repository is a local variable (So the only way to store it is copy\paste). I dont know how to do it best? any thoughts?

Actual namespace seems to not be working

Hiho all!

I've just updated to Symfony2.3 stable. Following the official composer.json structure I changed this:

"minimum-stability": "dev",

to this:

"minimum-stability": "stable",

And the line "doctrine/doctrine-fixtures-bundle": "dev-master", couldn't be loaded, so I changed to "doctrine/doctrine-fixtures-bundle": "1.0.*@dev",

It's loading, but when clearing cache this savage message appears:

Fatal error: Class 'Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle' not found in blablabla/AppKernel.php on line 22

Dunno why it isn't being recognized now... As far as I now there isn't ANOTHER namespace change, is it?

Greetings!

DoctrineFixturesBundle fails to load multiple fixture files through different connections and so different entity managers

EDIT: Assetic has changed its path, so you can remove assetic tags from app/config/config.yml and app/config/config_dev.yml to get rid of the error.

Hi,

i'm writting this thread in order to detail the full story about what's happening to me when working with multiple connections.

I have an Oracle database which is accessed by OracleBundle through oracle connection, then i have a MySQL database which is accessed by MySQLBundle using mysql connection. Inside MySQLBundle i have an entity which tries to store, as FK, a field which belongs to another entity which resides inside OracleBundle. AFAIK it can't be done by Symfony2, but in the testing process and before linking each entity with each other, so there are no FK to link each entity, while creating the above ( http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html ) "project" i noticed doctrine bundle can't manage multiple connections properly.

What's happening to me when working with multiple connections? If you download the tar.gz file you could see there is a FooBundle and a BarBundle, each one using its own connection an of course each own entity manager. Inside FooBundle there is Foo entity and inside Bar Bundle there is Bar entity, each one has each fixture to load some info to the database. The issue i'm talking about appears here when trying to load the fixtures.

**First i create both databases, each one using each own entity manage so also using each own connection:
php ./symfony doctrine:database:drop --connection="bar" --force'
php ./symfony doctrine:database:drop --connection="foo" --force'
php ./symfony doctrine:database:create --connection="bar"
php ./symfony doctrine:database:create --connection="foo"

**Then i successfully create the schema:
php ./symfony doctrine:schema:create --em="bar"
php ./symfony doctrine:schema:create --em="foo"

**And finally i try to load the fixtures which throughs me an error:
php ./symfony doctrine:fixtures:load --em="foo"
php ./symfony doctrine:fixtures:load --em="bar"

**That's the error i get, so i think Symfony has some kind of bug:
Created database for connection named bar
Created database for connection named foo
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!
ATTENTION: This operation should not be executed in a production environment.

Creating database schema...
Database schema created successfully!

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo_
[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myFooBundleBundle\Entity\Foo is not a valid entity or mapped super class.

doctrine:fixtures:load [--fixtures[="..."]] [--append] [--em="..."] [--purge-with-truncate]

**But if i randomly remove a fixture, no matter which one, everything runs fine:
mv src/myVendor/myBarBundleBundle/DataFixtures/ORM/Bar.php /tmp/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo

**But when both fixtures exists:
mv /tmp/Bar.php src/myVendor/myBarBundleBundle/DataFixtures/ORM/
php ./symfony doctrine:fixtures:load --em="foo"

purging database
loading myVendor\myFooBundleBundle\DataFixtures\ORM\Foo
loading myVendor\myBarBundleBundle\DataFixtures\ORM\Bar_

[Doctrine\ORM\Mapping\MappingException]
Class myVendor\myBarBundleBundle\Entity\Bar is not a valid entity or mapped super class.

Tag

Could you please tag a version as soon as you see fit ?

Subsequent fixtures drops embedded documents

I have a curious issue with fixtures and MongoDB. I don't even know, if this is the right place (actually I use https://github.com/hautelook/AliceBundle and didn't try it directly), I just assume that it may caused by this bundle.

I have a document with a list of embedded documents. As long as I run the corresponding fixtures on its own, or as the last fixture everything works fine, but as soon as another fixtures is executed it drops the embedded documents, but nothing else. This means, that the parent document remains, but the property and its values disappear from the database.

Worth to note, that the parent-document is also an extended one (via single-table-inheritance). However, I tried it and every other field, that is unique to the child-document doesn't disappear. Only the embedded documents.

Fixtures seems to have issue with aggregate fields as Id

Everything works perfectly as long as I have an id as primary key.
Like this

    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

But If I want my primary key to be the composed of the date and the servername.
I get the "Object of class DateTime could not be converted to string" error.
My entity

class MyEntity
{
    /**
     * @var ProxyServer;
     * @ORM\Id
     * @ORM\ManyToOne(targetEntity="Server")
     */
    private $servername;

    /**
     * @var date
     * @ORM\Id
     * @ORM\Column(name="date", type="date", nullable=false)
     */
    private $date;
}

My fixtures

model: MyEntity
tags: [ test, dev ] # optional parameter
save_in_reverse: false # optional parameter
persistence: orm # lets you choose if these fixtures should be saved through the orm or through mongodb.
fixtures:
    pt-d-1:
        servername: ps-1
        date: "-1 day"

Any idea where that problem come from ?

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.