Chapters
18 Chapters
|
1:54:58
|
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!
04.
Refactoring for SRP
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": ">=8.2",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "^1.11", // 1.11.99.1
"doctrine/annotations": "^1.0", // 1.12.1
"doctrine/doctrine-bundle": "^2", // 2.3.1
"doctrine/doctrine-migrations-bundle": "^3", // 3.1.1
"doctrine/orm": "^2", // 2.8.4
"knplabs/knp-time-bundle": "^1.15", // v1.16.0
"phpdocumentor/reflection-docblock": "^5.2", // 5.2.2
"sensio/framework-extra-bundle": "^6.0", // v6.1.2
"symfony/console": "5.2.*", // v5.2.6
"symfony/dotenv": "5.2.*", // v5.2.4
"symfony/flex": "^1.9", // v1.21.6
"symfony/form": "5.2.*", // v5.2.6
"symfony/framework-bundle": "5.2.*", // v5.2.6
"symfony/http-client": "5.2.*", // v5.2.6
"symfony/mailer": "5.2.*", // v5.2.6
"symfony/property-access": "5.2.*", // v5.2.4
"symfony/property-info": "5.2.*", // v5.2.4
"symfony/security-bundle": "5.2.*", // v5.2.6
"symfony/serializer": "5.2.*", // v5.2.4
"symfony/twig-bundle": "5.2.*", // v5.2.4
"symfony/validator": "5.2.*", // v5.2.6
"symfony/webpack-encore-bundle": "^1.6", // v1.11.1
"symfony/yaml": "5.2.*", // v5.2.5
"twig/cssinliner-extra": "^3.3", // v3.3.0
"twig/extra-bundle": "^2.12|^3.0", // v3.3.0
"twig/twig": "^2.12|^3.0" // v3.3.0
},
"require-dev": {
"doctrine/doctrine-fixtures-bundle": "^3.2", // 3.4.0
"fakerphp/faker": "^1.13", // v1.14.1
"symfony/debug-bundle": "^5.2", // v5.2.4
"symfony/maker-bundle": "^1.13", // v1.30.2
"symfony/monolog-bundle": "^3.0", // v3.7.0
"symfony/stopwatch": "^5.2", // v5.2.4
"symfony/var-dumper": "^5.2", // v5.2.6
"symfony/web-profiler-bundle": "^5.2" // v5.2.6
}
}
8 Comments
Hello!
In the ~6:41 timestamp, just after copying
ResendConfirmationEmailSenderclass fromtutorial/folder, Ryan said that he won't bother us testing that resend confirmation email, and we need to trust that it works... but, well, it seems I am this kind of rebel programmer, question all authorities ^^' and I checked that myself.. and it is not working.. right? That was merely the example to show us the SRP rule in use, but kinda incomplete (after I pasted thelocalhost:8000/resend-confirmationaddress in the Firefox, it threw405 - Method not allowedexception (showed the error page) [Screenshot] - so as, I suppose, it should have maybe a twig template where with some "Resend email" text/button?)I am watching it in April 2026, using php 8.3 (though, the Symfony framework, exact same as in the video - 5.2.6 (which is no longer maintained, - I know) - downloaded the code from "Downloads" and installed with Composer, as someone from your team recommended me in some other tutorial
I love the material, btw, I hope with Ryan's help I will finally learn SOLID principles, and with practice in php, within the best existing php framework! <3
Hey @Jan-Makarewicz
I'm glad to hear you are enjoying the SOLID tutorial (it took a lot of research to write). First, about the missing test, yes, Ryan didn't write a test to save some time and keep the tutorial focused on SOLID content, but in a real app, you should at least write a functional test for your routes
Second, the
405error, that's because the route only acceptsPOSTrequests. You navigated to that page manually, so that's equivalent to aGETrequest. You need to add a button somewhere and on click, submit a form withPOSTmethod.Cheers!
I did all of the OOP courses in the track (until this point), but non of them explained me what is the manager folder for. I only knew services and entities... Entities store data and services do some work with the data.... but manager?
Hey theNaschkatze,
Good question :) Actually, manager is a bad name to use because it really does not have much value in its name. Well, I bet people start using the "manager" suffix after Doctrine's EntityManager and so abuse this name in their own projects for their own services, but usually, there might be a better name for your services. Basically, manager is the same as service. So you can think about manager as just a service, nothing special, just a fancy name. But that's my personal opinion on it.
Cheers!
on mac control+option+O
hotkey to remove unused imports
Hey Xiro
Thanks for sharing hotkey tip! It may be very useful!
Cheers!
Why ConfirmationEmailSender is a concrete class and not an interface? Currently the caller is tied to this specific implementation and then to the specific template and synchronous mailer. Maybe I want to change the template based on the user who has just signed in, e.g. standard user, business user, gold user? Or I have recommendation links and depending on who recommended my site the template will differ (there even might not be any confirmation email for some users, and NullSender will be the way to use then)? Maybe I want to save the email in DB so a cron job will pick it up or want to send to some emails queue.
What I'm trying to say is that a caller should not care about the implementation. It should only care that it has a contract with an interface that the confirmation will be sent "somehow".
What do you think about it?
Cheers!
Hey Fabien,
those are goods points, and if your application requires such flexibility, then, adding an interface, so you can change the implementation based on your business rules makes perfect sense, but I wouldn't add an interface to protect my code from changes that I'm not sure about. I don't like to add unnecessary abstractions which only makes more difficult to understand your code. My advice here is "keep it simple" and let changes hit you first, then, you can adapt your code and improve its design based on real things not on a guess.
Cheers!
"Houston: no signs of life"
Start the conversation!