Chapters
23 Chapters
|
2:20:28
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!
Subscribe to download the code!
-
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!
23.
Making a Twig Extension (Filter)
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.3.0 || ^8.0.0",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"knplabs/knp-markdown-bundle": "^1.8", // 1.9.0
"sensio/framework-extra-bundle": "^6.0", // v6.2.1
"sentry/sentry-symfony": "^4.0", // 4.0.3
"symfony/asset": "5.0.*", // v5.0.11
"symfony/console": "5.0.*", // v5.0.11
"symfony/debug-bundle": "5.0.*", // v5.0.11
"symfony/dotenv": "5.0.*", // v5.0.11
"symfony/flex": "^1.3.1", // v1.21.6
"symfony/framework-bundle": "5.0.*", // v5.0.11
"symfony/monolog-bundle": "^3.0", // v3.6.0
"symfony/profiler-pack": "*", // v1.0.5
"symfony/routing": "5.1.*", // v5.1.11
"symfony/twig-pack": "^1.0", // v1.0.1
"symfony/var-dumper": "5.0.*", // v5.0.11
"symfony/webpack-encore-bundle": "^1.7", // v1.8.0
"symfony/yaml": "5.0.*" // v5.0.11
},
"require-dev": {
"symfony/maker-bundle": "^1.15", // v1.23.0
"symfony/profiler-pack": "^1.0" // v1.0.5
}
}
12 Comments
Hello, can't find the next course about database ?
Hey Mamour W.
At the moment we don't have a Doctrine tutorial based on Symfony5 but we do have a couple you might be interested. These are based on Symfony4 but majority of the content is still relevant
https://symfonycasts.com/sc...
https://symfonycasts.com/sc...
Cheers!
Hi Sf Pros, can TWIG also generate Images that are linked inside a Markdown-Text?
Example:
<div>{{ party.info ? party.info|markdown_to_html : ''}}</div>renders markdown-syntax as expectedbut images get not processed, the result looks like:
Take care: This preview is misleading, it adds „()“ inside the Image-Syntax. This is NOT the problem I have with My code.
Hello @Sebastian-O,
That's the problem of
asset()because it should be processed before markdown parser. Markdown knows nothing about twig asset function, and tries to fix broken markup. That's why you are receiving this type of result.So you can't have twig function saved in DB for the future parsing, it will not work.
Cheers
Thanks! I'll look for another solution.
All was fine until I moved the APP_ENV= variable into .env.local. After this I got
The option "dsn" with value ""https://xxxxxxxxxxxxxxxxxxx..."" is invalid. But not with xxxxxx... :)
Have I missed something?
Ryan, you're just awesome I don't know what name I can give you but it seems you already float in space so that's enough.
Cheers.
Hi guys!
Can you help me with some twig extension?
I want to embed partial controller in a template like this. Everything works, but I can't use dynamic name:
<b>dynamicName</b> is App\Controller\ArticleController::recentArticles
{{ render(controller(dynamicName, { section: section})) }}Got an error
<blockquote>Compile Error: Cannot declare class App\Controller\ArticleController, because the name is already in use</blockquote>
Then I tried to create an extension:
But got same error "the name is already in use"
Hey triemli!
Woh! This is very interesting! I more or less know how the render(controller()) functionality works, and I can't think of ANY reason why using a dynamic value would be a problem. I'm not saying your wrong about the error... but It think something else is going on. I especially think that since you tried to do this with a custom Twig extension and got the same result. Here is what I would try to test our theory: simply render:
Does that work? Or do you get the same error? If it DOES work... then triple check your
dynamicNamevariable. If it does NOT work, try to render a different controller from a different class. Usually (but not always) these "because the name is already in use" errors are because there is a typo in some class or namespace in some file and you, accidentally have 2 different "ArticleController" classes in different files.Cheers!
At the end it says in the next course we're gonna learn to use the database: where is that next course???
Hey Teo!
Thank you for your interest in SymfonyCasts tutorials! Yes, it will be covered in the next course, but we're working on that course right now. It should be released next soon, most probably after we fully released VueJS course, but I don't have any estimations yet. For now, the related most recent course about DB is this one: https://symfonycasts.com/sc... - but it's based on Symfony 4. If you don't want to wait for Symfony 5 related course - you may follow Symfony 4 one. The concepts should be the same. And of course, if you will get stuck somewhere following that course -just leave us a comment below the video and we will try to help you moving forward.
Cheers!
"Houston: no signs of life"
Start the conversation!