This is why Symfony 6 is perfect for your next project (PHP Framework)

Coding (PHP 8)

A quick introduction of Symfony 6 and other PHP Frameworks

I have built an entire website in only 3 days.


My secret?


I have used a PHP web framework!


And this article I’m going to show you exactly what you need to know to replicate what I did, step by step.


Let's jump in...


What is Symfony?


Let’s start with the very basics.


Symfony is a PHP framework.


You can use it for many reasons.

  • Improving your productivity
  • Make the development of your web app faster


It does that by implementing many reusable components.


Symfony is one of the most popular frameworks currently available in the PHP market.


To be able to learn it you need some basic knowledge before


They are:


Advantages of using a PHP framework


Before frameworks existed the only way to create a PHP application was by using vanilla PHP.


Photo by Riku Lu on Unsplash


Now there are many frameworks out there.


It is way easier to create web applications. 


Symfony provides plenty of tools already out of the box.


Alongside these tools, there are also many components you can use.


These can be built-in or third-party components that you can plug into the application.


HTTP requests, service containers, models binding, routers, configuration files, etc.



It needs time to create all the above systems.


In Symfony, you can reuse them many times.


“The only way to learn a new programming language is by writing programs in it.” — Dennis Ritchie


Coding Standards


Symfony has a few coding standards that you can follow to make the framework work at its best.


Another reason for following these patterns is that they improve the readability of your code.


If you use the same standard as other developers it will take them just a few seconds to understand the file system.


Here is a list of a few of them:


  • In a class, declare methods in the following orders: public, protected, private
  • In a class, declare properties before the methods
  • Only ONE class per file
  • ALWAYS use braces to control to show the structure body
  • Add a single space around binary operators
  • Add a single space after commas delimiters


Here is a page in the official Symfony documentation where you can find all those standards.


Coding Standards (Symfony Docs)


Symfony highlights these coding standards.


It is a good rule of thumb to use them even when you’re coding in vanilla PHP or using other frameworks.


Naming Conventions


Alongside coding standard is it also very important to follow the naming convention chosen by the framework.


There are many reasons for that.


One is code readability.


Another one is that Symfony does use a lot of reflection APIs to keep the system of classes under control.


Photo by Fabio Santaniello Bruun on Unsplash


Having a standard way to write code help keep these usable.


Here are a few rules that you need to follow:


  • use camel case for variable, functions, and methods’ arguments
  • use snake case for configuration parameters (also Twig template variables)
  • classes, interfaces, traits, and enums need to be in the upper camel case
  • interfaces, traits, and exceptions need to be suffixed with what they are


Here are some example


The Camel case looks like this:


$createdAt, public function getTimeCreation(){...} , getTimeCreation($currentTime) .


This is Snake case:


framework.csrf_protection, http_status_code


Upper camel case starts in uppercase:


ConsoleLogger, BlogController, CommentableInterface


Why use a framework?


Once upon a time, developers were responsible for writing every aspect of an application.






Now, these days are over and many functionalities are left to the framework.


Also, it is worth taking advantage of reusable packages so.


They are usually made by plenty of developers and are well-tested.


The goal of a framework is to help in the development process.


They provide standards and low-level capability.


This means that programmers can concentrate on the actual scope of the project.


Also, consider the number of developers adding improvements to the base code.


It enhances security and delivers plenty of support.


“Some tests are better than no test at all!” Fabien Potencier, creator of the Symfony framework


Not me mentions frameworks save time and money for you and your boss.


These days there is no need to reinvent the wheel and do things on our own.


Symfony Vs Laravel Vs CodeIgniter vs others


Nowadays There are many PHP frameworks out there.


Each of them has its own pro and cons but their main goal is the same.


Provide a structure and make the job of a developer easier.


Symfony is one of the most famous.


At the moment I am writing this article the latest version available is Symfony 6.


Symfony is very good because it provides plenty of stand-alone components that you can plugin into your project.


Photo by Linus Mimietz on Unsplash


Another advantage of learning Symfony is Drupal,


Drupal is one of the most important CMS on the internet.


And it has a very similar structure.


This means you can make blogs, eCommerce, and other types of online applications in a very fast way.


and Using the same skills you use to write Symfony applications.


Laravel is the most popular PHP framework right now.


Its pros are the fact that it is quite easy to use and provides a ton of functionality.


Also, the Laravel community is huge and you always find solutions for your problems.


The biggest problem is that Laravel provides plenty of built-in functionality.


These are assets but they make the system heavier, thus they slow down the applications.


If you want a lean and faster PHP framework instead, there are other many choices you can make.


“Truth can only be found in one place: the code.” ― Robert C. Martin


CakePHP, Codeigniter, and Yii are all great choices each with its own pro and cons.


The best way to choose among them is to get a bit of information and then test them.


Once you have done some experiments here and there you can check your favorite one.


If you want to start with a PHP framework now, I created an article describing how to install Symfony 6 and start to create a web app locally. 




This was a quick introduction to what a PHP framework is and why to use it in the first place.


Are you interested in learning more about Symfony?


If so, insert your email below and get notified when a new post is out!

If you like this content and you are hungry for some more join the Facebook's community in which we share info and news just like this one!

Other posts that might interest you

Coding (PHP 8) Nov 13, 2022

How to fix the PHP fatal error: allowed memory exhausted?

See details
Coding (PHP 8) Nov 18, 2022

The Discovery Phase of the Web Design Process

See details
Coding (PHP 8) Nov 29, 2022

How MVC framework works (basics)

See details
Get my free books' review to improve your skill now!
I'll do myself