DEV Community

Cover image for Choosing a PHP Framework over Core PHP
Yahaya Oyinkansola
Yahaya Oyinkansola

Posted on

Choosing a PHP Framework over Core PHP

Some of you may be saying, it is quite obvious that using a PHP framework is better than using core PHP and trying to even debate on this is a waste of time. Yes you are right to an extent because it looks that way at first glance without thinking much about it. I want to discuss in this article some of the reasons why a lot of developers and companies choose to build web applications and websites with a PHP framework rather than core PHP.

We software developers know that building software is all about choosing the right tools for the Job. It is important to compare and contrasts your options before going for what seems like the obvious best solution.

I have noticed how some developers encourage people who are new to programming to learn a framework without learning the language the framework was built on. This is not right because the person would most likely find it hard to understand what the framework is doing. Writing code i really understand makes programming more fun and interesting, and i guess you agree with me because you can manipulate the code the way you want to.

So who should you listen to?

The choice is yours, Experienced developers encourage the new devs to learn frameworks because of the many benefits it provides when building an application, but the same can be done with coding from scratch, even though it might take more time. In fact there are developers who have built their own structure from the ground up and have been using it for years to build web applications and websites for people, but it takes time to reach this kind of level and if you plan on reaching this point, it would be better if you build your own code structure as a side project which gives you the opportunity to know what works and what doesn't.

Reasons for choosing PHP Frameworks over Core PHP

  1. Core PHP is the PHP language itself. With Core PHP, you have more control over your code, you create the structure for your project the way you want it, make helper functions, create config files etc without being tied to any particular style. Having this control is great but with great control comes great responsibility. One thing to keep in mind is that you are handling and managing everything yourself, which can be quite daunting when it comes to handling a large application. This is the reason why building projects with Core PHP is not recommended in a real world setting by experienced developers because it can be very hard to maintain, especially if there is no proper documentation.

  2. Another issue with using Core PHP is the difficulty in collaborating with other developers. Developers would have to first understand your code structure, which can take time if the structure is really complicated. Having a well known code structure that even a new developer can understand makes the productivity of the whole team better.

  3. Having to reinvent the wheel, Who really wants to take time to code their own database abstraction layer?, any hands?, didn't think so πŸ˜‚πŸ˜‚.

    Writing a piece of code for a problem that has already being solved, tested and approved by other developers slows down the development of an application by a huge amount of time. For instance, trying to create a functionality that enables PDF files to be downloadable on a website is a waste of time when you have a package like mPDF that does that.

    Understand that "YOU REALLY DON'T NEED TO CREATE EVERYTHING FROM SCRATCH!!", and you would be more productive as a developer. It took me a long time to understand this, i always thought i would look like an amateur if i couldn't build things out from scratch. From the experience i have had in this field, it is good to build something from scratch when you are learning something new or building a side project, that gives you the opportunity to understand what you are doing on a much deeper level but when it comes to building a real world project, please don't try to reinvent the wheel again. It would waste both your time and the time of the client or company, except if you have built a good code structure in place already.

  4. The last reason is on PHP frameworks, they are the option most developers prefer and for good reasons. Frameworks provide the structure you need, the foundation for a standard web application has been layed out and the only thing you need to do is build on top of that foundation. With frameworks, you don't have to re-invent the wheel as common functions have been written such as helper functions, classes, database configurations and so on to give the developer a head start. Frameworks are easier to use and manage by many developers because of how they are structured and the support they provide. No matter how a developer writes code with a framework, any developer would be able to understand what is going on because the structure is common. It makes collaboration and prototyping easier, faster and more efficient. The only downside of some frameworks like Laravel is how heavy they can be, but not everything is a 100% perfect in the software industry, the most important thing is, does it get the Job done in the most efficient way possible?, if the answer is yes, then you should be okay with what you have.

Conclusion

Understanding which option to choose is very important so that you know why everyone goes for the option they go for. My advice is start from the basics and understand the language properly before learning how to use frameworks so that you appreciate frameworks more.

Top comments (0)