The course is built on Symfony 4, but the principles still apply perfectly to Symfony 5 - not a lot has changed in the world of relations!
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^1.6.10", // 1.10.2
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // v2.0.0
"doctrine/orm": "^2.5.11", // v2.7.2
"knplabs/knp-markdown-bundle": "^1.7", // 1.7.0
"knplabs/knp-paginator-bundle": "^2.7", // v2.7.2
"knplabs/knp-time-bundle": "^1.8", // 1.8.0
"nexylan/slack-bundle": "^2.0,<2.2.0", // v2.0.0
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"sensio/framework-extra-bundle": "^5.1", // v5.1.4
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.0.4
"symfony/console": "^4.0", // v4.0.14
"symfony/flex": "^1.0", // v1.21.6
"symfony/framework-bundle": "^4.0", // v4.0.14
"symfony/lts": "^4@dev", // dev-master
"symfony/twig-bundle": "^4.0", // v4.0.4
"symfony/web-server-bundle": "^4.0", // v4.0.4
"symfony/yaml": "^4.0", // v4.0.14
"twig/extensions": "^1.5" // v1.5.1
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.0.2
"easycorp/easy-log-handler": "^1.0.2", // v1.0.4
"fzaninotto/faker": "^1.7", // v1.7.1
"symfony/debug-bundle": "^3.3|^4.0", // v4.0.4
"symfony/dotenv": "^4.0", // v4.0.14
"symfony/maker-bundle": "^1.0", // v1.4.0
"symfony/monolog-bundle": "^3.0", // v3.1.2
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.0.4
"symfony/stopwatch": "^3.3|^4.0", // v4.0.4
"symfony/var-dumper": "^3.3|^4.0", // v4.0.4
"symfony/web-profiler-bundle": "^3.3|^4.0" // v4.0.4
}
}
8 Comments
I get an error "cannot find any references for class "App\Entity\Article"
while trying to the command ./bin/console doctrine:fixtures:load
I followed the steps and I understand the function and how it works but I can't seem to find where I messed up...
When running doctrine:fixtures:load, check on what file it stopped.
For my it was App\DataFixtures\CommentFixture.
To fix it just added dependent fixture:
Add getDependencies to App\DataFixtures\CommentFixture (also add implements DependentFixtureInterface).
So basicly:
class CommentFixture extends BaseFixture implements DependentFixtureInterface
{
...
public function getDependencies()
{
return [ArticleFixtures::class];
}
}
Hope it helps
Hey Tomek,
Makes sense, thanks for this tip!
Cheers!
Hey @Bob
I believe your problem is related to a dependent fixture not being load in the right order. Could you double check it?
Cheers!
I get an error after implementing the code in ArticleFixtures. When i execute ./bin/console doctrine:fixtures:load the error " Cannot find any references for class "App\Entity\Article"" appears.
What did i do wrong ?
Hey Kristof,
This is our custom exception, you can see it here: https://symfonycasts.com/sc... . So, if you get this - it means you call getRandomReference() for App\Entity\Article but this->referencesIndex array for this class is empty. Actually, see this chapter: https://symfonycasts.com/sc... - I bet you have invalid fixtures order, we had a similar problem there and have fixed it.
Let me know if it does not help.
Cheers!
Hey! I'm having a problem with the getRandomReferences function, I don't really understand what's going on, what is the difference between getRandomReference and getRandomReferences function and what should it return?
AND
should this look like:
$tags = $this->getRandomReferences(Tag::class);
$this->faker->numberBetween(0, 5);
or is it totally wrong?
THANKS!
Hey Alexander,
Based on the name we can see getRandomReference() returns only one object while getRandomReferences() returns many, i.e. returns an array of the objects. Ryan prepare that function for you, so you just need to copy/paste it and you'll see the code and what exactly it returns. So, let's wait for this video to be released, and I bet you will understand the difference easily ;)
Cheers!
"Houston: no signs of life"
Start the conversation!