Chapters
31 Chapters
|
3:19:40
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3
Subscribe to download the code!Compatible PHP versions: ^7.1.3
-
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!
05.
Absolute URLs to Routes & Assets
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!
This tutorial is built on Symfony 4.3, but will work well with Symfony 4.4 or 5.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3",
"ext-iconv": "*",
"aws/aws-sdk-php": "^3.87", // 3.110.11
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.10.1
"doctrine/doctrine-bundle": "^1.6.10", // 1.11.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.1
"knplabs/knp-paginator-bundle": "^2.7", // v2.8.0
"knplabs/knp-snappy-bundle": "^1.6", // v1.6.0
"knplabs/knp-time-bundle": "^1.8", // v1.9.1
"league/flysystem-aws-s3-v3": "^1.0", // 1.0.23
"league/flysystem-cached-adapter": "^1.0", // 1.0.9
"league/html-to-markdown": "^4.8", // 4.8.2
"liip/imagine-bundle": "^2.1", // 2.1.0
"nexylan/slack-bundle": "^2.1,<2.2.0", // v2.1.0
"oneup/flysystem-bundle": "^3.0", // 3.1.0
"php-http/guzzle6-adapter": "^1.1", // v1.1.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.1
"sensio/framework-extra-bundle": "^5.1", // v5.4.1
"stof/doctrine-extensions-bundle": "^1.3", // v1.3.0
"symfony/asset": "^4.0", // v4.3.4
"symfony/console": "^4.0", // v4.3.4
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "^4.0", // v4.3.4
"symfony/framework-bundle": "^4.0", // v4.3.4
"symfony/mailer": "4.3.*", // v4.3.4
"symfony/messenger": "4.3.*", // v4.3.4
"symfony/property-access": "4.3.*", // v4.3.4
"symfony/property-info": "4.3.*", // v4.3.4
"symfony/security-bundle": "^4.0", // v4.3.4
"symfony/sendgrid-mailer": "4.3.*", // v4.3.4
"symfony/serializer": "4.3.*", // v4.3.4
"symfony/twig-bundle": "^4.0", // v4.3.4
"symfony/validator": "^4.0", // v4.3.4
"symfony/web-server-bundle": "^4.0", // v4.3.4
"symfony/webpack-encore-bundle": "^1.4", // v1.6.2
"symfony/yaml": "^4.0", // v4.3.4
"twig/cssinliner-extra": "^2.12", // v2.12.0
"twig/extensions": "^1.5", // v1.5.4
"twig/extra-bundle": "^2.12|^3.0", // v2.12.1
"twig/inky-extra": "^2.12", // v2.12.0
"twig/twig": "^2.12|^3.0" // v2.13.1
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.2.2
"easycorp/easy-log-handler": "^1.0.2", // v1.0.7
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/browser-kit": "4.3.*", // v4.3.5
"symfony/debug-bundle": "^3.3|^4.0", // v4.3.4
"symfony/dotenv": "^4.0", // v4.3.4
"symfony/maker-bundle": "^1.0", // v1.13.0
"symfony/monolog-bundle": "^3.0", // v3.4.0
"symfony/phpunit-bridge": "^3.3|^4.0", // v4.3.4
"symfony/stopwatch": "4.3.*", // v4.3.4
"symfony/var-dumper": "^3.3|^4.0", // v4.3.4
"symfony/web-profiler-bundle": "4.3.*" // v4.3.4
}
}
12 Comments
Hello there ,
I not understand this part, "That's it! Symfony will detect the domain name". What if I'm sending email using command line? Symfony will not detect the domain name, how to configure that in my .env.local? I think, maybe this part is missing in this article. For all the rest, excellent article! Regards.
Hey Marco!
Excellent question! We tackle this a bit later in the tutorial: https://symfonycasts.com/sc...
And also, the config needed for this has been slightly simplified: https://symfony.com/blog/ne... - you can use our approach in the tutorial (it works fine!) or adapt to this new config.
Cheers!
Hi,
some images like the
logo in the email andthe Article images are not loaded and I don't understand why.All other images work.
I ran:
composer install
yarn install
yarn build
I'm using webpack encore for my other projects too, so I don't think it's related to my yarn/npm installation.
This is how the html looks like in the email:<img src="https://127.0.0.1:8000/build/images/email.logo.png" class="logo" alt="SpaceBar Logo">
The exception is : No route found for "GET /build/images/email.logo.png"My public folder contains the image tho I checked it : public/build/images/email/logo.66125a81.pngedit: the email logo was my fault a typo but the articles are still broken mybe its the twigextention/function?
Hey @Ecludio!
Hmm. Well first, good job debugging so far :).
For the article images that aren’t working, what does the final HTML look like? And what error do you get if you try those URLs directly on your browser?
Btw, there is some special logic to get these files set up correctly. When you load the fixtures, the ArticleFixtures.php file (in src/DataFixtures) does a, sort of, “fake” upload where it copies the image files into the public/. I’m not sure if this will help, but I wanted to highlight it.
Anyways, let me know what you find out!
Cheers!
Hi,
just to warn you that chapter 5 is not public, but chapter 6 is.
Thank you again for your work !
Ok that seems to have been fixed
Hey John,
Hm, most probably the problem was in a different thing, maybe temporary video outage... depends on the error you saw. Anyway, glad to hear it works for you now.
Cheers!
Isn't Symfony calling
strip_tags()instead ofstrip_slashes()?Hey AymDev,
Ah, you're right! We meant "strip_tags()" but said "strip_slashes()". I fixed it in https://github.com/knpunive...
Thank you for reporting it!
Cheers!
Love these twig tips. What is the best method to retrieve the root directory from within my command class? I could use DI to inject the KernelInterface and use `$this->kernel->getRootDir()`, or I can alternatively inject ParameterBagInterface and use `$this->parameterInterface->get('kernel.project_dir')`. I'm guessing these are pretty equivalent, but I don't know if there is a preferred or better way??
Hey Ernest H.
Yes there is another way, and we think it's best way to do such things. You can autowire using DI, in
services.yamlunderbindsection you can define something likeproject_dir: '%kernel.project_dir%'and then feel free to use it in any constructor like:Cheers!
thanks!
"Houston: no signs of life"
Start the conversation!