Phalcon – a ‘no compromises’ framework
Nowadays, most developers simply can’t imagine efficient web development without using frameworks, which make everything so much easier and faster. But as we all know, nothing is perfect. The bigger and more comprehensive the framework, the more likely it is to hurt the performance of your website or app. However, there is the Phalcon framework, which has come to challenge this precognition.
Phalcon is an open source PHP framework, first released in 2012.
Basically, every PHP framework claims that it’s unique, listing some specific features, design principles or impeccable documentation as a proof. But among all of these solutions, Phalcon comes off as truly unique. Unlike the majority of PHP frameworks, it’s not installed as a mere directory in your project, but instead is written in the Zephir language, parsed to C, compiled and delivered as a C-based extension of PHP. The goal of this approach was to make the framework faster without sacrificing features and downgrading to microframeworks. Did it work? Let’s see.
What is a framework?
During the last few years, we have observed a proliferation of PHP frameworks. By the term “framework” we actually mean a standardized set of ready-made tools and components that speed up app development. They help in writing applications that have a cohesive, readable, easy-to-understand structure (the MVC model in particular) and code. Unfortunately, this convenience comes at the price of efficiency. In most cases, the larger the framework, the more it affects the performance of the final product.
I want my small app to be fast – does this mean that frameworks will be useless for me?
Definitely not. If your app is small and performance is a priority, you can use the so-called microframeworks – smaller versions of larger frameworks that aim to provide very basic functionalities without sacrificing performance. That may work. But what if our app will require more and more complex components in the future to make full use of its potential and growing popularity? Chances are that it will have to be completely rewritten using another, more comprehensive framework.
Phalcon – the perfect balance between size and performance
When it comes to building apps – you’re not happy to compromise, right? If that indeed is the case then you should definitely take a closer look at Phalcon. This particular framework will provide you with all of the typical features of large and comprehensive frameworks, but at the same time, since it is delivered as a C-based module of the PHP language, its precompiled components make it much faster than the traditional ones written in pure PHP. Performance put aside, Phalcon’s approach to many typical solutions – such as dependency injection or services – greatly differs from those commonly employed by most PHP frameworks, proving to be far more practical. Another interesting and noteworthy fact is that the developers behind Phalcon have created a new high-level programming language called Zephir as part of the project. You can learn more about it here.
There are many good reasons why you should at least give Phalcon a try. Just to name some of the most important:
- It’s the fastest PHP framework out there,
- Its server resource usage is very low,
- It provides all the standard components, including ORM (built in support for both SQL and NoSQL), MVC, routers, REST, dependency injection, cache, template engines, ACL, and a lot more,
- It can be used both as a micro- and macroframework,
- Comprehensive and quality documentation is provided,
- Constant growth and access to help is ensured thanks to the growing and extremely friendly community.
- It supports PHP7.
So… is it, like, perfect?
Of course not, nothing is. Before you dive into Phalcon, you should know that due to its nature as a PHP module written in C, its setup is not that simple. It needs to be installed and compiled by an administrator. In some cases, you need to contact your hosting provider to do that for you. Quite often though, many hosting companies offer Phalcon out of the box. What’s more, debugging Phalcon’s kernel is quite complicated. On the other hand, it’s really well-polished and you won’t be stumbling upon too many bugs. If you really want to deep dive into Phalcon, you can always download a proper tool and debug its performance as you go. You can find detailed instructions on this subject on the official website of the Phalcon project.
A few words on speed
It’s really fast. But to give you a better picture, let’s have a look at some of the available benchmarks. We suggest you take a look here (for framework benchmarks) and here (for ORM benchmarks). Below, you can find results from the fourth quarter of 2015.
How to start your journey with Phalcon?
If you are wondering at this stage how to start using Phalcon, We suggest the following steps:
- If you use Vagrant, download and get familiar with the Vagrant development environment available on Github.
- If you use Docker, download this stable package as well as this Apache and PHP7 bundle that already includes the Phalcon framework.
- Windows users aren’t left empty-handed either – get a DLL library here.
- You will also need the list of commands necessary to install and compile Phalcon on Linux/Unix/Mac.
If you have any problems, the internet is full of quality resources. The most important ones include official documentation (available in multiple languages), the Phalcon and, of course, the well-known and beloved stackoverflow.com.
If you want to stay up-to-date – follow:
Phalcon provides a really unique and fresh take on PHP frameworks, and we believe it stands out enough to at least give it a chance. Perhaps, it will become your new tool of choice for building lighting fast web applications?