What Is a Framework And How To Choose the Right One?

If you want to program your first own portal, personal website, e-shop, home calendar or recipe generator, instead of laborious code shoveling, it’s sometimes advisable to look around for a pre-prepared solution. It’s similar to having a plot of land where you want to implement your project. It isn’t necessary to do everything yourself with your own two hands. To achieve the desired goal in the form of a house, your family, friends, community or a finished project from a neighbor can help. Well, in the case of programming, a framework can lend a helping hand. 

We aren’t talking about a ready-made solution, but about a skeleton or a rough structure, which you’ll subsequently adjust according to your own wishes. Using a framework means that you can make your development easier and focus on specific key functionalities of your project. If you’re a beginner, it’ll also help you learn, because frameworks usually have rich documentation and a lot of practical examples, as they’re maintained by large communities of programmers.

Choosing the right framework

If you have a driver’s licence, for sure you’ve heard from your family or friends that Volvo is the safest, Ferrari the fastest, Audi the most beautiful, Fiat Multipla the ugliest and so on. The same goes for choosing a framework. One is fast, another has a nicer syntax, and another will last longer in the event of a hacker encounter, making your application more stable.

If you have such an option, I recommend testing as many vehicles as possible, meaning trying as many frameworks as possible. You don’t have to drive for miles, just sit in, look around the interior and the exterior and maybe read some reviews or watch a test on garaz.tv.

Which one is the best?

The first way to choose the best framework can be its popularity. For many years, gold, silver and bronze have been held by the immortal Laravel, Symfony and CodeIgniter frameworks. Each of those has a large community, great documentation and thousands of active users. If you’d like to experiment, I’ll also tell you the names of other adepts – CakePHP, Yii, Laminas Project, Phalcon, Fat-Free Framework (F3), Lumen, Slim, Flight, PHPixie or Nette. These are smaller and should be used wisely. But we’ll talk about that later…

Now I come to the second way of choosing. As a programmer on a discussion forum once said, “Use the right thing on the right part of your business”. Just as the choice of the language itself is important, for example PHP, Node.js, Java or .Net, the choice of architecture (specifically the type of the design pattern), framework or even the decision to use only certain components from different frameworks, is equally important. 

I recommend focusing on 3 criteria:

  1. Don’t try to invent what’s already invented and try to choose components/frameworks that will help you reduce the amount of original code that you need to write at the beginning. 
  2. Don’t experiment unnecessarily, rather go for a standardized development process and follow proven practices. A super great framework will be useless if it doesn’t cooperate with the rest of the project.
  3. Focus on safety, sustainability and enabling team development. In short, if the only two people who know the framework are you and the person who invented it, you’ll probably end up at an impasse after a few months or years of development. More popular solutions that a community of programmers help improve and advance, are better.

And one more tip – don’t forget that it’s necessary to constantly monitor the versions. As PHP in itself evolves, so must every framework. We used to use PHP 4, 5, 7, now we have 8. Similarly, we started with Slim Framework in version 2.0 and today, at the time of writing this article, we’re already on version 4.10. And we’re replacing the Zend Framework 1, managed by Rogue Wave Software and associated with our company from time immemorial, with the Laminas Project. It’s a direct continuation of Zend Framework, with a new name and a new administrator – Linux Foundation.

Introducing one framework after another in detail in this blog won’t be useful to you. Google will immediately answer any questions in a number of articles where it’s very nicely broken down. Instead, I decided to describe 3 frameworks with which I have a good experience and I recommend you to at least try them on your project.

Slim Framework

If you want to create a clear and sustainable REST API for your application, I recommend e.g. Slim Framework. With the help of this great framework, you’ll achieve a perfect result with no trouble at all. Why? It’s the fastest micro RESTful framework. It has very good documentation and it’s easy to understand. In addition, it offers scalability and supports both PSR-7 (a set of common interfaces defined by the PHP Framework Interop Group) and code hooks. It also has useful classes for managing requests, responses, cookies, etc. and it uses a simple and straightforward concept for its middleware. All of this makes it a great framework to use on a wide range of projects.

How to install Slim 4 quickly and easily can be found here: https://www.slimframework.com/docs/v4/start/installation.html

Example: Defining REST API for football teams and their players.
Example: Simple home controller with help and status./em>

Laminas

If you like to use MVC architecture and want to develop a customized website while using something that’s already tested on a number of web projects, you can choose Laravel or Laminas Project. This framework has more than 570 million installations, good customizability and a large community behind it, guaranteeing great support and maintenance. In addition, it offers fast and powerful big data applications, with which you can easily handle even large enterprise applications.

How to install Laminas easily and quickly can be found here: https://docs.laminas.dev/laminas-mvc/quick-start/#install-the-laminas-mvc-skeleton-application

 

A simple example.

Nette

If you’re a complete beginner and want to support the community of programmers in the Czech Republic and Slovakia, you can choose Nette framework (https://nette.org/en). I grew up with it, so I couldn’t help but mention it. Although it’s been around for years, it’s a modern framework with support for HTML5, Ajax and SEO. It has quality documentation, template system, debugging tools, effective database layer and object design. All in all, it leads you to good habits, but at the same time it gives you enough freedom.

How to get started with it can be found here: https://doc.nette.org/en/quickstart/getting-started

A little bit of everything

Choosing the optimum solution is never easy. Often only years of practice will teach you that. Until then, you need to try, test, search and compare. This is how it works in our company too – our team is constantly growing and we always like to hear the opinion/defense of various old or new types of solutions from our new colleagues.

That’s why you’ll see Slim Framework or Laminas Project here, but you’ll try some components from Symfony and, if I’m not mistaken, you can also dig a little bit in Phalcon. And in future, when one of you readers becomes our colleague, it’s highly likely that as an analyst/architect, you and your team can implement a project in a completely new framework of your choice.