doctrine-ormfixturesnelmio-alice

Doctrine 2: doctrine:fixtures:load unexpected warning


I'm loading a yaml file using nelmio/alice bundle.

There's a weird behavior when including the second entity of a many to many relationship. when running the load command it throws a warning:

[Symfony\Component\Debug\Exception\ContextErrorException] Warning: copy(http://lorempixel.com/640/480/?35984): failed to open stream: Impossible to estabilish connection..

yaml file code is the following:

AppBundle\Entity\ComponentInstance:
    componentInstance_{1..30}:
      componentCode: <componentInstanceCode()>
      componentId: <numberBetween(1,50)>
      sectionInstance: '@sectionInstance_*'
      date: <datetime()>
      images: '@componentImage_{1..2}'

AppBundle\Entity\ComponentImage:
    componentImage_{1..4}:
      imageName: <name()>
      imagePath: <image()>
      imageAlt: <text()>
      width: <numberBetween(100,500)>
      height: <numberBetween(100,500)>
      components: '@componentInstance_{1..2}'

As I put comments on the ComponentImage part it works without any problem. There is no track of that url inside the whole project.

the image() function is the following:

public function images()
    {
      $genera = [
          '/images/color_pencils.jpg',
          '/images/half_color_pencils.jpg',
          '/images/rainbow_wood.bmp',
          '/images/color_smoke.jpg'
      ];
      $key = array_rand($genera);
      return $genera[$key];
    }

Any suggestion?


Solution

  • The problem came out being a mix of a couple of elements.

    I made a typo caling

    imagePath: <image()>
    

    instead of <images()>

    The second, and more confusing point was that <image()> is reserved keyword of nelmio/alice bundle which automatically generates an url to http://lorempixel.com

    by calling the correct function it loads the data correctly