Unable to locate any services for fixtures to load

This question has been asked multiple times before:

  1. Symfony 3.4 and Fixtures Bundle issue with bundle version 3.0
  2. Symfony 3.4.0 Could not find any fixture services to load
  3. Symfony Doctrine can't find fixtures to load
  4. Could not find any fixture services to load - Symfony 3.2

None of the above solutions have helped me so far. Here is my current configuration:

Composer.json

"require": {
"php": ">=7.0",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/orm": "^2.5",
....
},
    "require-dev": {
        ....
        "doctrine/doctrine-fixtures-bundle": "^3.0",
}

I have a custom Bundle that was working fine with PHP 5.6, Doctrine bundle ^1.6, doctrine orm ^2.5, and fixture bundle ^3.0.

This bundle contains some fixtures in VendorName/BundleName/DataFixtures/ORM, each fixture class is declared as follows:

Class MyFixture1 extends Fixture implements OrderedFixtureInterface,FixtureInterface, ContainerAwareInterface{
    ...
}

The services are defined in VendorName/BundleName/Resources/config/services.yml which is loaded by this function:

public function load(array $configs, ContainerBuilder $container)
{
    $configuration = new Configuration();
    $config = $this->processConfiguration($configuration, $configs);

    $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
    $loader->load('services.yml');
}

In VendorName/BundleName/Resources/config/Services.yml I have tried various configurations without success:

services:
_defaults:
  autowire: true
  autoconfigure: true
  public: false

VendorName\BundleName\:
  resource: '../../*'
  # you can exclude directories or files but if a service is unused, it's removed anyway
  exclude: '../../{Entity,Repository,Tests,EventListener}'

I also tried explicitly pointing to the DataFixtures directory:

 VendorName/BundleName\DataFixtures\:
  resource: '../../src/VendorName/BundleName/DataFixtures'
  tags: ['doctrine.fixture.orm']

Additionally, I attempted manually configuring the service:

VendorName\BundleName\DataFixtures\ORM\MyFixture1:
  class: VendorName/BundleNamee\DataFixtures\ORM\MyFixture1
  tags: ['doctrine.fixture.orm']

Unfortunately, I continue to encounter the error message. Any insights on what could be going wrong here? It used to be possible to specify the bundle for fixtures manually in the past, but that seems no longer viable.

UPDATE 1: Apologies for omitting the error message: "Could not find any fixture services to load"

Answer №1

After finding guidance in the recommended answer, I was able to make progress and get things working properly. It became clear that while cache could potentially be a hindrance, having Fixtures within your own bundles necessitates proper registration.

For those using SF 5.1.*, I went ahead and created a services_dev.yaml file with the following content:

services:
  // other config
  Namespace\Registered\In\Composer\For\Fixtures\:
    resource: '../vendor/path/registered/in/composer/to/fixtures'
    tags: ['doctrine.fixture.orm']

Once this setup was in place, clearing the cache allowed everything to function as intended.

I also included *_dev in the services.yaml file, which serves as Symfony's way of loading it only when in a development environment (based on the APP_ENV Environment variable).

Answer №2

If you've found your way here, I was able to resolve my issue. Here are some tips that may help:

  1. Make sure the Bundle is enabled in the AppKernel
  2. Clear Symfony cache by running php bin/console cache:clear --env=dev (or env=prod)
  3. Delete the cache folder manually

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The Infinite Scroll feature is malfunctioning when the $(window).scrollTop() is greater than or equal to $(document).height() - $(window).height() - 10

JavaScript: $.ajax({ type: 'POST', url: 'getcontent.php', data: 'lastid=' + 0, dataType: "html", success: function (data) { console.log(data); $("#content").appe ...

Working on a PHP tokenizing algorithm

I have a Perl script that tokenizes a string using separators. @s=split /([^a-zA-Z \t\-\'\,\.]+)/, $_[0]; # Tokenized with separators For example, if I have the string $s="The large [[bear]] is dangerous." It will return a ...

The resulting line will consist of the discovered string

Let's say there's an interesting HTML document presented below with associated line numbers: 30 - <div id="myDiv"> 31 - <span class="mySpan">Some Text</span> In this scenario, PHP is being utilized for a specific purpose: $ ...

I fail to comprehend the reason behind the slowing down of processes when minifying is implemented

I seem to have encountered an issue while using the fat free framework which offers a built-in function for minifying multiple CSS/JS files into a single file. I initially believed that this would enhance optimization; however, it appears to have the oppos ...

Is there a way to customize the color of specific sections on a dygraph chart?

I am looking to incorporate dygraphs into my website, but I need help with displaying a specific background color in certain parts of the chart. For example, I want the chart to show green during daylight hours. Can you assist me in achieving this? ...

Loading data onto a different JQGrid when a row is selected using OnSelectRow

For the past few days, I have been struggling with a perplexing issue. Here's a brief overview of the problem - I'm working with JqGrid 4.2.0 (the latest version available at the time of writing) and have two grids on a single page. The left grid ...

Transform your cURL command to cURL PHP code equivalent

I am new to cURL and AJAX. I have been trying to learn on my own, but I am struggling to figure out how to convert a cURL CMD script into a cURL PHP script. Below is my cURL CMD script: curl 'https://example.url' ^ -H 'authority: example. ...

Issues arise when attempting to resubmit a PHP+JQuery+AJAX form with new values

I'm having trouble understanding why my form isn't refreshing after changing the values. Let me explain further, I have a password recovery form where users enter their email address. The form is processed in PHP using AJAX and displays a valida ...

Turning off the button in CakePHP

Is there a way to create a function that, when a disable button is clicked for a record, it changes the value in the 'active' column to 0 within the ['Album'] array? The default value of this column should be set to 1. I have tried: if ...

Switch up the Thumbnail Image based on the selected category

While testing a shopping site I created, I encountered an issue with changing the banners at the top of the page based on the category the user is viewing. This site is hosted on a server on my localhost, not using wordpress by the way. <div class=" ...

What is the one letter prefix commonly used for PHP class constants?

Have you ever noticed how many (if not all) PHP constants have a single-letter prefix, such as E_NOTICE, T_STRING, and so on? When creating a series of class constants that are interrelated, do you tend to stick with this convention or do you lean towards ...

Access-Control-Allow-Origin causing a one-of-a-kind session problem

When trying to access data using cross-domain requests from multiple domains, I have included the following code in a PHP file at the backend: header("Access-Control-Allow-Origin: *"); Each time a new session is created for every request, resulting in a ...

Missing symbol in character encoding for imagettftext function in PHP GD

Recently, I encountered a challenge with the formatting of a string that I received. Initially, it appeared as: Ciel Spa at SLSâ„¢ is a celestial dreamscape Fortunately, my script was able to transform it into: Ciel Spa at SLS™ is a celestial drea ...

What is the best way to retrieve upload progress information with $_FILES?

HTML: <input type="file" value="choose file" name="file[]" multiple="multiple"/><br/> <input type="submit" class="submit" value="confirm" /> <input type="hid ...

A guide to utilizing dependency injection in phpunit tests for Magento 2

I've been utilizing env.php to store my configurations, which is why I'm looking to implement dependency injection in my test class in order to access the configs. How can I inject the config class 'Magento\Framework\App\Deplo ...

Determine the domain for a POST method request

Is there a way to determine the domain of another website when receiving a POST request from it? For example, if helloworld.com sends a POST request to mywebsite.com, how can mywebsite.com identify that the request is coming from helloworld.com? I have a ...

Dynamic MediaWiki Page Title Feature

Currently, I am in the process of creating a customized skin for MediaWiki (Version 1.15) and one of my main objectives is to incorporate the title of the page being accessed into the design of the skin. However, I am encountering difficulty in figuring ...

When an Ajax post request is made, the data being sent is appended to the JSON response

Having a dilemma with my ajax call: $.ajax({ url: '/assets/functions.php', type: 'POST', data: { "functionCall": "get-uploads", "type": type }, dataType: 'json', success: function (data ...

Using PHP Hover should apply CSS styles exclusively to the specified element

I have a piece of PHP code that displays cards. What I need: When a user hovers over the entire element, I want to make the title bolder, move the arrow to the left, and zoom in on the image of that particular hovered element. <div class="posti-class ...

Inquiry regarding the encryption methods I am using

After implementing a login system, I took steps to enhance its security. First, I generated a salt for the passwords: $salt = openssl_random_pseudo_bytes(1024); file_put_contents("salt.txt", $salt); Then, I hashed the passwords using the whirlpool algori ...