Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7503435
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:13:16+00:00 2026-05-29T21:13:16+00:00

How do you control the order of fixture loading when two fixtures depend on

  • 0

How do you control the order of fixture loading when two fixtures depend on each other to load?

My schema has a Book entity, an Author entity, and a BookAuthor entity. Books can have many authors, and BookAuthor is required because it has an additional field called ‘main’ indicating whether the author is the main author of the book.

In BookFixtures, I reference BookAuthorFixtures:

$book1->addBookAuthor($manager->merge($this->getReference('book-author-1')));

In BookAuthorFixtures, I reference BookFixtures:

$bookAuthor1->setBook($manager->merge($this->getReference('book-1')));

One of the fixtures must be loaded first, which means the fixture it references is an undefined index.

Is there a trick to solving this issue?

This question addresses almost the same issue, but the configuration is different and the issue went unresolved despite the accepted answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T21:13:19+00:00Added an answer on May 29, 2026 at 9:13 pm

    I don’t know exactly how did you set up your relationships, but I think that this is what you should do:

    1) Load the Author fixtures (they should require any books to be created)

    2) Load the Book Fixtures. While you are creating the fixtures, in your load() method, you can create the “BookAuthor” entity for each book, and the book entity should be configured to save the BookAuthor entities it holds when it’s persisted. The property “book_authors” inside the book entity could be something similar to this:

    /**
     * @ORM\OneToMany(targetEntity="your\bundle\Entity\BookAuthor",mappedBy="book", cascade={"persist", "remove"})
     */
    protected $book_authors;
    

    So in the Book fixtures, the code snippet that creates a book might be (don’t forget to set any extra data, it’s just a sample):

    // [...]
    $book = new Book();
    $book->setTitle( 'xxx' )
    // Set more data...
    $book_author = new BookAuthor();
    $book_author->setAuthor( $manager->merge($this->getReference('author-1')) );
    $book_author->setBook( $book );
    $book->addBookAuthor( $book_author );
    
    $em->persist( $book );
    
    // [...]
    

    I hope it helped!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In order for the user to control the volume , my android application has
Can I control the order static objects are being destructed? Is there any way
I can use the MS Word ActiveX control in order to access some parameters
Is there any (simple) way to get some control of the order in which
I have a segmented control where the user can select how to order a
How can I control the order of virtual functions in the virtual table? Are
Google chrome has a very nice speech recognition control in it's browser. For example
Is there any way to control the order of which the GridView control renders
I have subclassed the RadioButtonList control in order to create a Control Adapter that
I'm using Django forms in my website and would like to control the order

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.