title: Symfony4: Loading fixtures from bundle
body: <p>I am trying to add fixtures from a bundle to the fixtures in my application. The fixtures reside in a subdirectory in my bundle under <code>lib/MyCompany/MyBundle/Fixtures</code>.</p>
  
  <p>Example:</p>
  
  <pre><code>// MyCompany/MyBundle/Fixtures/SpecialFixtures.php
  &lt;?php
  
  namespace MyCompany\MyBundle\Fixtures;
  
  use Doctrine\Bundle\FixturesBundle\Fixture;
  use Doctrine\Common\Persistence\ObjectManager;
  
  class SpecialFixtures extends Fixture
  {
      public function load(ObjectManager $manager)
      {
      }
  }
  
  </code></pre>
  
  <p>Then I use this fixture in my application as a dependency to another fixture</p>
  
  <pre><code>// src/Fixtures/DependentFixtures.php
  &lt;?php
  
  namespace App\Fixtures;
  
  use MyCompany\MyBundle\Fixtures\SpecialFixtures;
  use Doctrine\Common\Persistence\ObjectManager;
  use Doctrine\Bundle\FixturesBundle\Fixture;
  use Doctrine\Common\DataFixtures\DependentFixtureInterface;
  
  class DependentFixtures extends Fixture implements DependentFixtureInterface
  {
      public function load(ObjectManager $manager)
      {
      }
  
      public function getDependencies()
      {
          return array(
              SpecialFixtures::class,
          );
      }
  }
  </code></pre>
  
  <p>My naive approach of using the command and expecting it works like written in the <a href="https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html#loading-fixtures" rel="nofollow noreferrer">docs</a></p>
  
  <p><code>./bin/console doctrine:fixtures:load</code></p>
  
  <p>fails with </p>
  
  <pre><code>Fixture "MyCompany\MyBundle\Fixtures\SpecialFixtures" was declared as a dependency, but it should be added in fixture loader first.
  </code></pre>
  
  <p>Trying to add the fixtures directory in the extension's load function also does not work, since the service <code>doctrine.fixtures.loader</code> is not defined during loading of the extension class of the bundle. Although this service shows up in the list of services in <code>./bin/console debug:container</code>.</p>
  
  <p>How can I tell the fixtures loader were to find additional fixtures that are managed inside of a bundle?</p>
  
  <p>Any help would be much appreciated.</p>
  
  <p>Cheers</p>
  
  <p><strong>Remark</strong>: Heavily redacted after first comment.</p>