DEV Community

Dawid Cyron
Dawid Cyron

Posted on

How I went from hating PHP to actually enjoying it

As programmers, many of us have their programming language preferences. I was always a fan of Java, but I also enjoy writing code in JavaScript or GoLang. Lately, I had to give PHP one more chance, and it joined a list of my favorite programming languages, and that's why I'm writing this post.

The beginnings

My first time coding in PHP was about 2 years ago. I was in my junior year of high school when we started learning about server-side web technologies. Back then, I mostly coded in Java, focusing on mobile apps, although I also knew other languages like JavaScript. When I first saw PHP, it looked weird. From the very beginning, one of the things that I hated the most was prefixing the variables with a $ sign, and it still feels weird to this day. Back then we had to use PHP 5.3 (enforced by education system), which definitely didn't make our lives better. May I say, I didn't spend much time after classes learning PHP.

Exams - the second chance

A bit over half a year ago I started revising for my exams in January 2019. That was when I decided to give PHP a second chance. Because we can't choose which programming language we want to use for our exams, we were forced to used PHP, so I had to learn it anyway. Because the exams are surprisingly easy, and they usually revolve around connecting to a database and fetching or inserting a few rows, I had to expand on the material. I decided to write a small e-commerce project. I created a simple online store application, with a basic user and product management and user authentication. I decided to avoid using frameworks at that time, as I wanted to experience pure PHP. While I hoped for the best, I was disappointed. Not only was I slower with PHP than I was with Node.js, but I also didn't enjoy coding that much. There was something about PHP that felt clunky, old. After I finished this app, I decided that PHP is not for me, and I went back to languages that I enjoyed, such as JavaScript with Node, or Java with Spring.

Summer internship - the breakthrough

Three weeks ago, I started my second internship as a programmer. Even tho my skills mostly revolve around Spring and GoLang, I was assigned to a PHP team. I and my colleague were tasked with rewriting an app based on Wordpress. At first, I was a skeptic. As you already know, I didn't like PHP much, nor did I like Wordpress. But because I didn't really have much of a choice, I decided to go through with it. Our superior suggested that we use Symfony 4, a framework that he wanted to try out. Because neither I nor my colleague had ever worked with Symfony, we knew we would have to start from the basics. And to be honest, I don't think any of us expected to be as positively surprised as we currently are. The beginnings were hard. Of course, working with frameworks like Spring gave me a solid foundation, as Symfony is very similar in many aspects, but there was still a lot to learn. What we quickly started appreciating was how quick and easy it is to create a lot of basic stuff in Symfony. Entities, controllers, repositories, data fixtures. All of that can be generated using CLI, which can really speed up your work. Additionally, things like authentication and authorization, which can be a challenging task to implement correctly from the ground up, can also be generated and used by executing one CLI command. Three weeks in, our performance increased significantly. We can now progress at a much faster pace, utilizing CLI tools in areas where they make our lives easier. We still have a long way to go before we fully understand Symfony, but at the moment it allows me to work at the same or even faster pace than I did with other technology. With time, I managed to overcome the syntax problem, in part thanks to Symfony's consistent naming conventions. Database wise, Doctrine significantly reduces the time that would normally be required to write all of the required queries. All of that makes the workflow much more enjoyable, and allows for much better productivity.


The main takeaway should be, don't worship programming languages, and don't hate the ones you don't like. All languages have their place, and after 2 years I discovered that with PHP. I will continue using other programming languages like Go, but I will definitely keep an eye on both PHP and Symfony.

Discussion (0)