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
}
}
14 Comments
Hello guys! Why didn't you use softdeletable behaviour from StofDoctrineExtenstion? Is there any reason?
Hey Dominik,
First of all, because this screencast is not about StofDoctrineExtenstion but about Doctrine relations. StofDoctrineExtenstion has many useful behaviors we didn't use here, but that's because we just don't want to stretch this course' time. We just wanted to show how you can install and start using the bundle, but as I already said we didn't have an aim to show all its features. So, if you need softdeletable behavior - go for it :)
I hope this helps.
Cheers!
Hello, guys,
In this video while I was coding along with you and tried to perform "symfony console doctrine:fixtures:load" command, I got this error: "Warning: Invalid argument supplied for foreach() " . I tried to add -vvv at the end and I got this:
"Exception trace:
at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php:170
Doctrine\Common\DataFixtures\Loader->addFixture() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/doctrine-bridge/DataFixtures/ContainerAwareLoader.php:44
Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader->addFixture() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/doctrine/doctrine-fixtures-bundle/Loader/SymfonyFixturesLoader.php:60
Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader->addFixture() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/doctrine/doctrine-fixtures-bundle/Loader/SymfonyFixturesLoader.php:44
Doctrine\Bundle\FixturesBundle\Loader\SymfonyFixturesLoader->addFixtures() at /Users/tautvydas/PhpstormProjects/Lesson_3/var/cache/dev/ContainerPiTxZ4K/getDoctrine_FixturesLoadCommandService.php:40
ContainerPiTxZ4K\getDoctrine_FixturesLoadCommandService::do() at /Users/tautvydas/PhpstormProjects/Lesson_3/var/cache/dev/ContainerPiTxZ4K/App_KernelDevDebugContainer.php:364
ContainerPiTxZ4K\App_KernelDevDebugContainer->load() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/dependency-injection/Container.php:441
Symfony\Component\DependencyInjection\Container->getService() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/dependency-injection/Argument/ServiceLocator.php:40
Symfony\Component\DependencyInjection\Argument\ServiceLocator->get() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/console/CommandLoader/ContainerCommandLoader.php:45
Symfony\Component\Console\CommandLoader\ContainerCommandLoader->get() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/console/Application.php:551
Symfony\Component\Console\Application->has() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/console/Application.php:640
Symfony\Component\Console\Application->find() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/framework-bundle/Console/Application.php:116
Symfony\Bundle\FrameworkBundle\Console\Application->find() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/console/Application.php:254
Symfony\Component\Console\Application->doRun() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/framework-bundle/Console/Application.php:82
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/symfony/console/Application.php:166
Symfony\Component\Console\Application->run() at /Users/tautvydas/PhpstormProjects/Lesson_3/bin/console:43
exit status 1"
I tried to remove the code from this lesson entirely and perform fixtures load command, but I still receive the same error. The problem is, I can't figure out what causes it. Is there a way to perform a command or smth and find out exactly where this problem arises?
Thank you very much in advance!
Hey Tautvydas!
Nice work adding the -vvv to get the stacktrace :). The error does, "sort of", show you were it's happening: there is apparently a foreach on line 170 of this file: /Users/tautvydas/PhpstormProjects/Lesson_3/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Loader.php. I would check that out... I can't see exactly what that is, because I'm not sure what the precise version is of this library that you're using.
My best guess is that it is this: https://github.com/doctrine/data-fixtures/blob/39e9777c9089351a468f780b01cffa3cb0a42907/lib/Doctrine/Common/DataFixtures/Loader.php#L170
And if I'm correct, then apparently one of your fixtures classes has a
getDependencies()method, which is not returning an array.Let me know if that's what it is!
Cheers!
Hello, Ryan!
Indeed, I made a mistake in "getDependencies()", because I forgot to add the square brackets in the return statement. Thank you for your help!
Btw, I really enjoy learning from you, guys!
Thanks Tautvydas you are welcome!
Hi, found little typo in getDependencies() should be plural ArticleFixtures ie.: return [ArticleFixture::class];
Hey Jindrich,
Thank you for reporting it! Could you clarify where exactly did you find that type? I mean, in the video? On what time? Or do you find it in the scripts below video? Or maybe in downloaded code? More context will help me to figure out where the problem is and I fix it.
Cheers!
Uh, oh. wrong thread.
It belongs to scripts bellow the video https://symfonycasts.com/sc...
Sorry for confusion.
Hey Jindrich,
Ah, now I see! Thank you for letting us know! Yes, we had fixed it in the code but forgot to fix it in code blocks. Not it's fixed there too in https://github.com/knpunive...
Cheers!
Hey there!
For me this part did not work:
if (!$comment->isDeleted()) {
$comments[] = $comment;
}
Schouldn't it be
$comment->getIsDeleted()
there?
Hey Andreas,
Thank you for this report! You're correct, it should be getIsDeleted() in PHP code. I fixed it in https://github.com/knpunive...
Cheers!
Last code block: $comments[] $comment; <-- missing =
Hey Chris!
Woooops, my fault! Thank you for this report! I fixed it in https://github.com/knpunive...
Cheers!
"Houston: no signs of life"
Start the conversation!