Ludovic Frank - Freelance developer

As a developer, Symfony is my framework of choice.

ionicons-v5-k Ludovic Frank May 2, 2022
115 reads Level: Confirmed beginner

Hello there,
Like every week, we're getting together for a little article. This week, I'm going to write an article that's been on my mind for a long time.
We're going to talk about Symfony and why it's my framework of choice as a web developer.
Are you ready? Let's get started!

My discovery of Symfony

In fact, in my life as a developer, my first encounter with Symfony went very badly... It wasn't its fault or mine.

The first time I met him, I was a student, already quite geeky, coding in PHP, Delphi... My OS was Debian, so you get the picture.
So in class, we were shown Symfony and told how revolutionary it was, the "MVC" and all that, yes, why not?

The problem? The only project we've ever done with Symfo was a "Hello World".
So you can imagine my reaction at the time: "Why load all that m****", when a simple ".php" file with "echo 'hello world';" and that's it ...

To understand its usefulness, you would have needed something more complex to get your teeth into.For example, at the time, if we'd created a mini-app with user management, it would have been clear that it was "brilliant".

A few months later, for a personal project, I tried again, the project being much more complex, I said to myself "Ah yes... Indeed?..." At the time, there were some useless bundles in the application, but it didn't matter, the time it saved me was what I saw.

Since then, I've moved on to many other Techs, depending on project needs and, above all, because you often have to make do with what already exists... but I always come back to it.

An Open Source framework

Obviously, I can't do an article on Symfony without mentioning the fact that it's Open Source, so it's possible to go and see how it works, suggest modifications... and so on.
The problem with Open Source is finding a viable business model, and one of the ways in which Symfony can make a living is through SymfonyCast.

Symfony, the framework for one person

To be honest with you, I took this phrase from DHH, but I also use it for Symfo.

The idea is actually quite simple: with Symfony, you can achieve your goals quite easily without having a team of 10 developers, unlike other technologies, which are very difficult to access, and these developers have to be highly specialized.
For example, Redux requires a great deal of understanding before it can be used properly. Of course, Symfony and Redux aren't there to solve the same problem, but when I think of a complex technology, I immediately think of Redux.

Symfony is not complex, in my opinion. You can easily implement things before you know everything about Symfony. You don't know SQL? Well, don't worry... Your complex pages will make 300 queries, but it'll work and when you're able to create your own DQL queries (doctrine overlay to SQL), you can optimize that (if there's a real need).

The idea here is quite simply that you don't have to master every aspect of the framework and understand how everything works in order to work.However, I'd like to take the opportunity of this article to give you a piece of information that I think is crucial: take the time to look into Symfony's event system, "EventSubscriber" and "EventListener". Personally, I'm more of a fan of "Subscriber", so I'll let you browse the doc and find out why?.

Concept compression

Again, this comes to me from DHH and his 2018 Rails conference, the idea of "Conceptual compression" is that you have to simplify things over time.

Let's take a very telling example:
In the 2000s, in companies, there were people whose job it was to protect and maintain the integrity of databases.
Today, this job exists less and less, as things have evolved.

First of all, we're now running on SSDs rather than platter disks, which, let's face it, is much more reliable. Secondly, database management systems have also evolved and are more reliable than ever.
Finally, today, companies are increasingly delegating this part of their business to cloud service providers such as AWS, Google Cloud and Microsoft Azure.

That's what concept compression is all about.
You have to understand that the human brain has its limits, that you can't be an expert in every hyper-complex technology by being a specialist in this kind of technology, so the only way out in the long term is very simple: make a career in very large companies, because only they can afford to pay these specialists.

Personally, I'm not interested in that at all. I'd rather master a good Symfony, which lets me do lots of things, than be hyperspecialized in React/Redux. After that, it's up to the individual to decide.

Focus on what really matters

After the previous paragraph, I think it's a good idea to take examples of what I'm talking about. No one's fallen asleep, are you okay?

An "SEO Friendly" CMS

Now let me tell you the story of the site you're on, and the CMS that runs it - no, it's not Wordpress.

When I decided to take the plunge into freelancing and entrepreneurship, the first thing I worked on was this site.

I wanted to have my own CMS, very light; one that would allow me to concentrate on the essentials: content and SEO.
Here's what I had in mind:

  • Must rank well on search engines
  • Must be ergonomic
  • Must load very quickly

The third was essential, but could wait. In fact, it's essential because you, my readers, are kind enough to give me your time. Reading my nonsense every week, it's out of the question for me to waste your time with pages that take 5 seconds to load... You've got much more interesting things to do... But this feature could wait, because back then... NOBODY read my nonsense.

The very first version of this site came out of the ground in 3 - 4 days, using Symfony and Bootstrap for the theme (which I've since scaled down).

It was far from perfect, but in 3 days I had a scalable site, already online, which allowed me to quietly start the SEO work, because SEO takes a long time, especially with a newly purchased domain.

Then, in parallel with my customer projects, I deployed small patches to improve SEO and the user experience, but at the time, I hardly had anyone coming to see me, so that could wait.

My foundations for solid SEO were there, but I still had a lousy score on PageSpeed, which didn't matter, because I knew how to improve it, and when I had the time, I'd do it.

One day... the time had come. That day was when, with over 90% of my traffic coming from Google Search and other search engines, a lot of you were starting to read me.

So I took two weeks and changed everything... so as to explode load times (for example, when loading this article, the server responds to the first request in less than 40 ms).
I focused only on what I needed to get good performance and be SEO Friendly (knowing that for that, technique isn't enough).

In short, today I have my CMS and I like it, it's fast and it references itself very well on search engines (try it yourself?).

To sum up, this site runs on :

  • GNU/Linux: Ah, because there are other OS? Don't I know it?
  • Symfony: The framework behind the CMS, so of course there's PHP.
  • NGINX: My Web Server of choice since 2013.
  • Varnish: Another crazy tech from the Unix/Linux world?

Symfony + Sylius = A cool e-commerce store

After talking about the Symfo-based CMS, let's talk about another project I've done with Symfony and its buddy Sylius

Finally, one of those I can freely talk about (NDA all that, all that...).

My partners wanted an online store, but something nice. And above all, they had very specific needs. We're talking about a company that's not at all into tech, so everything had to work and remain simple:

  • Good SEO (yes, again!)
  • Outstanding customer experience for an SME
  • Automation of order dispatch to the people who prepare them
  • Automated creation of delivery labels (so that order-pickers only have to stick them on)
  • Accounting report at the beginning of each month (so you know what VAT has been collected, etc.).

As you can see, once again I focused more on what it needed to be rather than "how I was going to do it", in the Symfony world there's an e-commerce framework called Sylius.

So I took a look at it... It follows Symfony principles, it's clean... GO HOP, come here you....

It took me a week to familiarize myself with Sylius. In fact, it's Symfony with an overlay, for example, in terms of templating, they have their own block system that uses the Symfony vent system, which is clever!

Sylius isn't a CMS, it's a framework, and you need to understand that it's not turnkey. You need to know how to code to adapt and use it.
By default, it includes the bare minimum needed to create an e-commerce site (and that's fine, isn't it?).

Personally, I took it over and imported my SEO Friendly modules (you know where they come from by now).

Then I started to concentrate on things that really had value (the e-commerce problem has long since been solved!).

Spending time on the user experience, we in tech are used to all these interfaces... and understand how to use them, but on this e-commerce platform there are people who aren't used to the Internet...

Let me give you an example:
When you select "Click & Collect" and on the next screen the site displays a billing address, some people get scared and think that "Click & Collect" hasn't been validated. But it's actually showing a "billing address".

It's this kind of small detail that ruins your user experience.
And that's what I needed to focus on. Not on hyper-complex technical problems.

I then coded the modules for automating all the processes I mentioned above.

Shortly after the launch of the store, we said to ourselves "what if we accepted crypto", so here we go ... a little module to integrate "UTRUST" and we're good ... (coded in an afternoon).

Once again, I enjoyed myself here, because it allowed me to work on what really counts, the final app. Is it easy to use? Does it make you want to use it? Does it give you confidence?

Then, to work on performance (on that front, I'd still have to make some changes).

Let's talk about PHP

This is where the more purist among you will be waiting for me.
It's true that Symfony is a PHP framework, a programming language that's basically a lot of tinkering ... but, in computing, what isn't basically a lot of tinkering? JavaScript? It's the same, if not worse.
I agree, there are still some really weird things in PHP, like putting "<?php" at the beginning of each code file, or using a "+" for incrementation and a "." for concatenation.

And worst of all, the "$" for ? variables.
But in recent years, the work done on this language has been simply amazing...

In fact, I started getting really interested in PHP again when the Opcode cache was implemented, and the performance went crazy...

Every time there's a new update, crappy stuff is removed.
The last straw was PHP 8.0 and the attributes (no, because... code in the comments, we see you, eh).

PHP 4 was a disaster, but the language has only improved since then, and today it's really not unpleasant to work with and I don't have much to reproach it with.

Ah well, of course... to remain backward-compatible, there are still some weird things, but you can't have everything.


And so, my little article comes to an end.

As you'll have gathered, what I like about Symfony is that it lets me concentrate on what's really important when I'm developing.

On that note, I'll see you next week?