Several weeks ago I decided to knuckle down and get the new version of CodeReviewVideos.com out from the safe confines of my desktop, to the scary world of Production.
“How much work can it be?”, I thought, rather foolishly.
It turns out that I had completely underestimated the scale of the task.
As an indicator of just how poor my estimation was, I thought it would take ~2 days. It has taken 3 weeks 🙂
But the good news is: it’s done!
Well, of course, I say done, but what I really mean is it’s ready to launch but there’s still a whole raft of improvements yet to come.
Ok, so to set the scene:
My vision for the next major release was to separate the front end and the back end entirely. This means the front end code (React/Redux) lives in one GitLab repo, and the back end (Symfony) lives in a different GitLab repo. The only way they interact is via HTTP requests.
This has worked really well, but came with a whole bunch of ‘gotchas’ that I hadn’t planned for.
There’s still a big one on my todo list: the Sitemap.
For CodeReviewVideos when using Symfony with Twig I made use of Presta SiteMap Bundle. This works really well. It does the job it sets out to do, and generally gets out of the way.
However, being that the back end is now simply a JSON API, I cannot use Presta SiteMap Bundle any longer – after all, Symfony is no longer aware of every available route.
It’s not a show stopper, but it does delay me switching the site over completely until I figure it out.
Then there’s the Mobile Responsive view.
Even though it’s 2017, and one of the first things I do when I wake up in the morning is to roll over and check my phone, I still routinely forget to test my dev projects outside of Desktop view.
As such, it only dawned on me on Tuesday this week that hey, perhaps I better check what the site looks like for mobile. And needless to say, it didn’t look good 🙂
There have been a bunch of other issues, particularly with Bootstrap / CSS. I decided to go with Bootstrap 4 for this one – figuring it would be relatively easy to do large chunks of copy / paste from the existing site to the new one.
Again, not so.
Whenever I use an image in a video write-up I use the css class of img-responsive which means, as you likely will have guessed, the image scales nicely depending on the screen size.
In BS4 they have removed img-responsive. Now it’s img-fluid. Even though it sounds minor, it still involves a bunch of MySQL tomfoolery to find and update each instance, and that all costs time.
Anyway, I could go on, and on… and on about this but that wouldn’t be much fun for anyone, I’m sure.
I really just wanted to share this as I’ve had conversations with other fellow developers in the past and have found sometimes they believe it’s a problem personal to them. Like they should have anticipated every potential problem and planned accordingly. Launching stuff is hard 🙂
It wasn’t all work on the new site this week. Heck no.
I managed to get three new videos up, too.
Are you using Events in your code?
If not, you may be missing out on a way to separate and (from one perspective) simplify your code.
I use Events all the time.
In this video we look at Symfony’s Event Subscribers, and how they can be used to split up your logic into easily digestible chunks.
And that’s all great, but sometimes a real world example can illustrate the point a lot better, so…
This video covers one way I’m using custom Events and Event Subscribers to respond to ‘things’ (some may call them: Events) that happen in my code.
For the purposes of this example I want to show how I use an Event Subscriber to help process incoming POST requests when using Symfony as a JSON API.
In just over three minutes, the aim of this video is to show how easy this setup is to use inside a real code base. I say real, because aside from changing some variable / object names, this code is ripped directly from the new version of CodeReviewVideos 🙂
Alas, using Events in Symfony isn’t all happy paths and hi-5s. There are some potential gotchas.
In this final video in this short series we cover some – potentially – unintuitive ways that Events behave inside Symfony. This stuff may be obvious to you, but all of these problems are things I have experienced as points of pain for other fellow devs in real projects.
Watch this video and keep your blood pressure at its normal level 🙂
If you haven’t received an invite to test out the new site, and you’d like one, please do get in touch.
Please don’t take it personally if you haven’t received an invite – I’ve been basing it on the most recently logged in users during the exact times I’ve been sending out invites, and only in groups of twos and threes.
PHP North West is next weekend.
If you are planning on being there, I’d love to meet up and say “hi” in person. Please get in touch if so.
Ok, until next week, have a great weekend and happy coding.