Chapters
29 Chapters
|
3:14:24
|
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!
01.
Flex, Versioning & extra.symfony.require
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!
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.3.0",
"ext-iconv": "*",
"antishov/doctrine-extensions-bundle": "^1.4", // v1.4.2
"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": "^2.0", // 2.0.6
"doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // 2.1.2
"doctrine/orm": "^2.5.11", // v2.7.2
"doctrine/persistence": "^1.3.7", // 1.3.8
"easycorp/easy-log-handler": "^1.0", // v1.0.9
"http-interop/http-factory-guzzle": "^1.0", // 1.0.0
"knplabs/knp-markdown-bundle": "^1.7", // 1.8.1
"knplabs/knp-paginator-bundle": "^5.0", // v5.0.0
"knplabs/knp-snappy-bundle": "^1.6", // v1.7.0
"knplabs/knp-time-bundle": "^1.8", // v1.11.0
"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.3.0
"nexylan/slack-bundle": "^2.1", // v2.2.1
"oneup/flysystem-bundle": "^3.0", // 3.3.0
"php-http/guzzle6-adapter": "^2.0", // v2.0.1
"phpdocumentor/reflection-docblock": "^3.0|^4.0", // 4.3.4
"sensio/framework-extra-bundle": "^5.1", // v5.5.3
"symfony/asset": "5.0.*", // v5.0.2
"symfony/console": "5.0.*", // v5.0.2
"symfony/dotenv": "5.0.*", // v5.0.2
"symfony/flex": "^1.0", // v1.21.6
"symfony/form": "5.0.*", // v5.0.2
"symfony/framework-bundle": "5.0.*", // v5.0.2
"symfony/mailer": "5.0.*", // v5.0.2
"symfony/messenger": "5.0.*", // v5.0.2
"symfony/monolog-bundle": "^3.5", // v3.5.0
"symfony/property-access": "4.4.*|5.0.*", // v5.0.2
"symfony/property-info": "4.4.*|5.0.*", // v5.0.2
"symfony/security-bundle": "5.0.*", // v5.0.2
"symfony/sendgrid-mailer": "5.0.*", // v5.0.2
"symfony/serializer": "4.4.*|5.0.*", // v5.0.2
"symfony/twig-bundle": "5.0.*", // v5.0.2
"symfony/validator": "5.0.*", // v5.0.2
"symfony/webpack-encore-bundle": "^1.4", // v1.7.2
"symfony/yaml": "5.0.*", // v5.0.2
"twig/cssinliner-extra": "^2.12", // v2.12.0
"twig/extensions": "^1.5", // v1.5.4
"twig/extra-bundle": "^2.12|^3.0", // v3.0.1
"twig/inky-extra": "^2.12", // v2.12.0
"twig/twig": "^2.12|^3.0" // v2.14.4
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.0", // 3.3.0
"fzaninotto/faker": "^1.7", // v1.8.0
"symfony/browser-kit": "5.0.*", // v5.0.2
"symfony/debug-bundle": "5.0.*", // v5.0.2
"symfony/maker-bundle": "^1.0", // v1.14.3
"symfony/phpunit-bridge": "5.0.*", // v5.0.2
"symfony/stopwatch": "4.4.*|5.0.*", // v5.0.2
"symfony/var-dumper": "5.0.*", // v5.0.2
"symfony/web-profiler-bundle": "4.4.*|5.0.*" // v5.0.2
}
}
27 Comments
Hi! Are there any tools for creating redirects in Symfony 5?
For example, I need 301 redirects. Can this be implemented? There are a lot of such redirects and registering them on the server side is not very convenient.
Hey Dmitriy!
There are many possible tools here... but it depends on what you need to do :). Are you migrating your site to some new platform... and so many of the URLs are changing? Or something else? In Symfony, you can:
1) Create a route & controller, then use
return $this->redirectToRoute('route_name', 301)to do a 301 redirect.2) You can go even easier and do the whole redirect just by writing a route: https://symfony.com/doc/4.4/routing.html#redirecting-to-urls-and-routes-directly-from-a-route
3) Or if you want some dynamic system where you can create redirects in the database, we use ZenstruckRedirectBundle - https://github.com/kbond/ZenstruckRedirectBundle (though it still needs a Symfony 5 support release!)
Or... you can do other things :p. We run our DNS through Cloudflare, which allows us to do redirects at the (sort of) DNS level without writing any code.
Let me know what you're trying to do and if any of these fit.
Cheers!
Thank you, Ryan.
I chose the second method and created redirects routes in routes.yaml.
I used package ZenstruckRedirectBundle before until I upgraded to Symfony 5 ( though it still needs a Symfony 5 support release). It’s good that I don’t have many redirects )
So, first i get this error:
! PHP Fatal error: Uncaught Symfony\Component\Debug\Exception\ClassNotFoundException: Attempted to load class "DoctrineCacheBundle" from namespace "Doctrine\Bundle\DoctrineCacheBundle".<br />!! Did you forget a "use" statement for another namespace? in /drv/Data/odd.solutions/dev/symfony5-upgrade/start/src/Kernel.php:33<br />!! Stack trace:<br />!! #0 /drv/Data/odd.solutions/dev/symfony5-upgrade/start/vendor/symfony/http-kernel/Kernel.php(429): App\Kernel->registerBundles()<br />!! #1 /drv/Data/odd.solutions/dev/symfony5-upgrade/start/vendor/symfony/http-kernel/Kernel.php(130): Symfony\Component\HttpKernel\Kernel->initializeBundles()<br />!! #2 /drv/Data/odd.solutions/dev/symfony5-upgrade/start/vendor/symfony/framework-bundle/Console/Application.php(159): Symfony\Component\HttpKernel\Kernel->boot()<br />!! #3 /drv/Data/odd.solutions/dev/symfony5-upgrade/start/vendor/symfony/framework-bundle/Console/Application.php(65): Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands()<br />!! #4 /drv/Data/odd.solutions/dev/symfony5-upgrade/start/vendor/symfony/console/Applicatio in /drv/Data/odd.solutions/dev/symfony5-upgrade/start/src/Kernel.php on line 33<br />!! <br />Put a # in front of the line about DoctrineCacheBundle in bundles.php, but then this happens:
!! <br />!! In DefinitionErrorExceptionPass.php line 54:<br />!! <br />!! Cannot autowire service "App\Repository\ApiTokenRepository": argument "$reg <br />!! istry" of method "__construct()" references interface "Symfony\Bridge\Doctr <br />!! ine\RegistryInterface" but no such service exists. Try changing the type-hi <br />!! nt to "Doctrine\Persistence\ManagerRegistry" instead. <br />!! <br />!! <br />!!And I'm giving up now.
Hey odds!
Don't give up! :) These are both normal errors - and we talk about them later in the tutorial - https://symfonycasts.com/sc...
The tl;dr is that a few type-hints need to be updated on your repository classes and can remove the DoctrineCacheBundle (when it was uninstalled, it should have been removed automatically from bundles.php, but if it wasn't you can remove it manually).
Let me know if that helps!
Cheers!
I love symfony cast :)
Hey Virgile,
Haha, thank you for this feedback! I also noticed you had a problem before you edited the comment, glad you were able to solve it yourself, well done! ;)
Cheers!
I'm trying to give you some rest :p
Thanks you a lot for your daily support Victor :)
Cheers!
Hey Virgile,
Hahaha, thanks! Do my best ;)
Cheers!
What did I do wrong?
Hey Robertas Š.!
I think I might know the problem. After downloading the code, make sure you run
composer install. That's mentioned in the README.md file, but you may have missed it :). Or, if you did run that and something else is wrong, let me know.Cheers!
Yep, I forgot to add info from composer install command:
Hey Robertas Š.
Looks like you need to install the
XSLPHP extension first. This guide may help you out https://bobcares.com/blog/php-extension-xsl/ but it depends on your OSCheers!
Hi !
I have an issue in the setup of the project.
When I execute doctrine:fixtures:load (with the project source code / start), I have this error :
`Careful, database "symfonycasts_symfony5-upgrade" will be purged. Do you want to continue? (yes/no) [no]:
> yes
> purging database
> loading App\DataFixtures\UserFixture
> loading App\DataFixtures\TagFixture
In Parser.php line 3195:
Notice: Trying to access array offset on value of type null
doctrine:fixtures:load [--append] [--group GROUP] [--em EM] [--shard SHARD] [--purge-with-truncate] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>`
I'm in php 7.41, and mariadb 10.4.10
Thank's a lot
Romain
Hey Romain L.!
Thanks for the report! It looks like there is a bug in PHP 7.4 and doctrine/orm - it requires doctrine/orm version 2.7.1 or higher to fix it. We're going to work to upgrade affected tutorials, but you can (for now) work around the issue by running:
Cheers!
Hello! I have some problem with installing project code source. Articles' thumbnails (for example http://localhost:8000/media/cache/resolve/squared_thumbnail_small/article_image/mercury-5e84d2b2a3664.jpeg) give response with 500 error 'Unable to create image for path "article_image/mercury-5e84d2b2a3664.jpeg" and filter "squared_thumbnail_medium". Message was "An image could not be created from the given input"'. I have PHP 7.3.6, GD extension settings:
`php --ri gd
gd
GD Support => enabled
GD Version => bundled (2.1.0 compatible)
GIF Read Support => enabled
GIF Create Support => enabled
PNG Support => enabled
libPNG Version => 1.6.28
WBMP Support => enabled
XBM Support => enabled
Directive => Local Value => Master Value
gd.jpeg_ignore_warning => 1 => 1`
Can someone help with fixing this error, please?
I figured out how to fix my problem. The GD extension wasn't properly installed. I use docker-compose for my project environment and this response helped me.
Hey Dariia M.
That is awesome that you solved issue by yourself, however feel free to ask any questions, we will be happy to help!
Cheers!
Hey there!
Part of my team is arguing for not upgrading too frequently, but rather from LTS (4.4) directly to next LTS (5.4) as a good practice for enterprise systems.
Is this the right way, or is it preferrable to take the minor version steps that are denoted to be somewhat short-lifed? While I personally am not happy with the idea of waiting two years for upgrading to Symfony5, reasonable arguments against it are having frequent updating work for being on short-lifed minor versions all the time.
Do you have a recommendation, which update strategy to follow best ?
Thanks for the good work!
Hey Markus L.!
I would *love* to tell you that upgrading to every minor version is the best idea... it's way more fun :). But honestly, from an enterprise system perspective, going from LTS to LTS is the "most stable" way to go. That's exactly why the support intervals for the LTS's overlap by 1 year: so that large projects can wait until 5.4 and then have 1 year to go from 4.4 to 5.4. The minor versions DO have such short lives... that if you're trying to stay on top of them, it can be difficult in a big project :).
WE upgrade every minor version... but WE make tutorials... so if we're not on the latest versions, shame on us ;). Enterprise is different.
One exception to this rule would be if a new feature comes out. For example, if you were on Symfony 3.4 and then wanted to use Symfony Messenger in 4.3 (pretend that is the latest version currently), then your team could make a one-time decision to jump from 3.4 to 4.3 to get that new feature.
I hope that helps!
Hello!
I have an issue.
I try execute "composer update symfony/*" as its said in tutorial. But response is: "zsh: no matches found: symfony/*"
MacOS Catalina 10.15.2
Symfony 4.3.*
composer 1.9.3
Hey Xiro
Try wrapping it between double quotes
# composer update "symfony/*"
Cheers!
Oh, thanks! That helped!
Hi my composer.json section does not contain "require" attribute. Сan i add this manually?
"extra": {
"symfony": {
"id": "01C9D5CVHAG...",
"allow-contrib": false
}
}
Hey Dmitriy,
What Symfony version do you have? Do you have Symfony Flex installed in your project? In theory you could add it manually, but it just might not work. IIRC the Symfony Flex is responsible of that, so try to install (or update to the latest) Symfony Flex first, it should add that automatically. If not - you can try to add that manually I think.
Cheers!
Hi there, i hope that you will make a complete tutorial about security including make:user make:auth make:registration-form and another thing that is very important email confirmation for every subscriber before he gets the right to logIn
Hey The early Bird!
Thank you for your interest in SymfonyCasts tutorials! We do have a tutorial about security, and we do cover many things related to users registration, authentication, and authorization. Have you watched that course by chance? It's called "Symfony Security: Beautiful Authentication, Powerful Authorization", you can find it here: https://symfonycasts.com/sc...
If you do, could you leave a feedback about what in particular was not covered by that course that you would like to see in the new tutorial?
P.S. About "email confirmation" - yeah, this topic is not covered in our tutorials yet, mostly because it's pretty straightforward feature. But we're going to include this topic in new Symfony 5 series :) And we already started working on Symfony 5 tutorials, you can check the first one here: https://symfonycasts.com/sc...
Cheers!
"Houston: no signs of life"
Start the conversation!