Chapters
23 Chapters
|
2:22:24
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.4.1
Subscribe to download the code!Compatible PHP versions: ^7.4.1
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
10.
Entity objects in Twig
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial also works great for Symfony 6!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.4.1",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^2.1", // 2.1.1
"doctrine/doctrine-migrations-bundle": "^3.0", // 3.0.2
"doctrine/orm": "^2.7", // 2.8.2
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"knplabs/knp-time-bundle": "^1.11", // v1.16.0
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"sentry/sentry-symfony": "^4.0", // 4.0.3
"stof/doctrine-extensions-bundle": "^1.4", // v1.5.0
"symfony/asset": "5.1.*", // v5.1.2
"symfony/console": "5.1.*", // v5.1.2
"symfony/dotenv": "5.1.*", // v5.1.2
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.1.*", // v5.1.2
"symfony/monolog-bundle": "^3.0", // v3.5.0
"symfony/stopwatch": "5.1.*", // v5.1.2
"symfony/twig-bundle": "5.1.*", // v5.1.2
"symfony/webpack-encore-bundle": "^1.7", // v1.8.0
"symfony/yaml": "5.1.*", // v5.1.2
"twig/extra-bundle": "^2.12|^3.0", // v3.0.4
"twig/twig": "^2.12|^3.0" // v3.0.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.3", // 3.4.0
"symfony/debug-bundle": "5.1.*", // v5.1.2
"symfony/maker-bundle": "^1.15", // v1.23.0
"symfony/var-dumper": "5.1.*", // v5.1.2
"symfony/web-profiler-bundle": "5.1.*", // v5.1.2
"zenstruck/foundry": "^1.1" // v1.5.0
}
}
14 Comments
noob question about docker. I set up the database service with mariadb, yadda yadda, turned off the machine, turned it back on today and was quite surprised that the
questiontable we created in the migrations chapter was still there, even though mydocker-compose.yamldoesn't say anything about volumes. so let's see -- the state of the database persists in the docker image after you shut down the container? so, you only lose your db data if you <i>destroy</i> the image? If so, that seems reasonable enough!Hey davidmintz!
Yup, I think you basically got it! Well, let me clarify one point. When you "turn off" a container, you can do one of two different things:
A)
docker-compose stop. This turns off the containers, but does not delete them. It's like turning off your computer.B)
docker-compose down. This turns off the containers and removes them. It's like turning off your computer then destroying the hard drive.So, I believe that it's less about "destroying the image" and more about "destroying the container" (which was built from the image). A minor detail, but for understanding things, it might help :). To further the distinction, you could have multiple containers that are all built from the same image, but they each of their own, separate data (e.g. the hard drive of each was built FROM the image, but is now its own, standalone machine).
Cheers!
Gee, I thought I was getting it but now I really <i>am</i> confused! (-: I'm kidding -- sort of. I do
docker-compose downbut it doesn't seem to destroy the "hard drive", i.e., the data in the database. I get the sense that where the docker docs say "remove" in this context, they mean remove from memory, not delete from disk. True?And it feels as though
stopis rather like hitting pause... no wait. I see docker also has itspausecommand. Never mind -- I'll get it all straight at some future date.Could not show question name and question on the page, instead getting this error "Object of class App\Entity\Question could not be converted to string
"
I managed to solve the issue by overriding the __toString method in Question class.
Hey Ibrahim,
Well done! Yes, that error means that you need to add a __toString() magic method to teach the PHP how to convert your object into a string, or call the method explicitly in a place where you're trying to "print" the object.
Cheers!
Weird thing is. I dont get autocomplete and question.name doesnt work. But question.getName() does work!
Is that okay? Or is it weird?
Hey Farry7
It's not strange, it happens to me from time to time. Symfony plugin is not perfect, I usually trigger a "clear index" (inside PHPStorm settings) action and it solves the problem
Cheers!
At 0:55 in my IDE it doesn't autocomplete the records, is there some way to make my PHPStorm like yours?
Hey Gediminas N.
Do you have Symfony plugin installed and enabled in your PHPStorm?
Cheers!
Hey sadikoff ,
Yes
Wow that's weird. Try to check plugin configuration, fix path inside it. There is old default config, which needs to be adjusted after plugin enabling. On main plugin settings you should check
appandwebdirectories they should point tosrc/andpublic/also translation paths should be adjusted. Also it's good to checkTwig,ContainerandRoutingtabs. The best way to get everything work here is to press reset to default buttonCheers! I hope this will help!
Hi,
2:53 little html issue.
By adding parse_markdown filter, the question goes out of p.d-inline tag :/
New paragraphs are generated by markdown.
Cheers!
Hey Steven!
Haha, yea, you're 100% right :). I noticed this when I was editing the video... but too late then. So yea, in reality, the
ptag around the processed markdown should probably be a div, otherwise you get p tags inside of p tags.Cheers!
"Houston: no signs of life"
Start the conversation!