We continue our PHP frameworks series with our take on Phalcon. Phalcon is a high-performance MVC-based framework for PHP. Phalcon was created by Andres Gutierrez and collaborators looking for a new approach to traditional web application frameworks written in PHP. The name is a combination of words “PHP” and “Falcon” (which is one of fastest birds in the world). It was originally released in 2012. Unlike most of the other PHP frameworks, Phalcon is implemented as an extension written in C in order to optimize performance. This is intended to boost execution speed and reduce resource usage.
If your main priority is requests per second, and you don’t want to deal with the added complication of switching to HHVM and/or learning the nuances of Hack, check out Phalcon. It’s crazy fast.
Category 1: Core Framework Design:
From what I’ve learned, Phalcon is an MVC framework that is very similar to most other modern MVC frameworks in structure and design.
1. MVC support
2. Thin controllers
Yes, but this is less a function of the framework and more a design philosophy, and responsibility of the developers. It’s also less of a priority if the framework makes it easy to unit test controller actions.
3. Exception handling at framework level
4. Inheritable configuration with respect to environments and installation across servers
Yes, the Phalcon config class has a merge function and examples are easy to find.
5. Overhead required to create basic module configuration
Minimal, Phalcon-devtools provide a command line interface to create skeletons of most important class object types.
6. PHP 5.5+ support
7. Event management framework
Yes, using Phalcon\EventsManager.
8. Dependency injection support
Yes, using Phalcon\DI.
9. Ease of bootstrapping and integrating with PHPUnit
Yes, though I didn’t get it working in a reasonable amount of time. I ended up extending phpunit directly rather than the Phalcon phpunit extension, so I’m not sure what advantage it provides.
10. UI templating support
Yes, Phalcon uses Volt, which looks very similar to Twig plus the ability to add custom extension functions.
11. Command Line Interface (CLI) to execute applications
Yes, using Phalcon\CLI\Task.
12. Support for manipulation of various data formats like JSON and XML
13. Useful debugging tools – such as logger support with customizable log levels, DB call instrumentation and request parameter logging.
phalcon-devtools command line interface for code generation, but nothing as comprehensively useful as the debug toolbars that are built into Symfony and Yii.
What’s coming next?
Category 2. Performance, Scalability and Redundancy
Did I mention that Phalcon is fast?
1. Support for application caching
Yes, frontend caching and backend caching with support for memcached, Redis, Mongo DB, etc.
2. Special features or capabilities focused on performance
Phalcon is written as a C extension, so it’s faster than any other PHP framework I’ve worked with.
3. Proven adoption on large projects
This list is a bit underwhelming.
Category 3. Security
1. Modules for security such as authentication, authorization and granular access controls
Authentication is handled though Phalcon\Security. Access control uses role and resource classes in Phalcon\ACL.
2. Frequent security patching
At the time of this writing, the most recent GitHub commit was 4 hours ago.
Category 4. Instrumentation and Troubleshooting support
Phalcon integrates with Xdebug and other standard PHP debugging tools, but doesn’t introduce anything particularly helpful from a debugging standpoint.
1. Instrumentation metrics or accessibility at the method level
Nothing built into the framework.
2. Instrumentation metrics or accessibility at the SQL level
Nothing built in, but there are multiple logging adapters. Using them to profile SQL queries would however require more than just a config setting.
Category 5. Database and Object-Relational-Mapping (ORM) Support
1. Support for models that interact with relational databases used at the client, specifically MySQL and Oracle, and possibly MariaDB in the future
2. Support for fine tuning of the SQL used in the ORM
Yes and no. SQL is abstracted through Phalcon Query Language (PHQL).
3. Support for interaction with NoSQL databases like MongoDB
Category 6. Community Support
Phalcon is actively maintained and has a forum for asking and answering specific questions.
1. Active maintenance and periodic releases
The most recent commit was today. The most recent stable release was 2 months ago.
2. Large developer community, support and discussion forums
3. Ability to run on a wide variety of Linux and Unix platforms such as RedHat, CentOS, Ubuntu, and MacOS
Yes, but since Phalcon runs as a C extension, you may run into problems installing in a shared hosting environment.
4. Well-documented – up-to-date with current release
Documentation provides useful examples and the forums are active for more specific questions.
I wouldn’t recommend using Phalcon, mostly because I saw the words “segmentation fault” in multiple commit comments on GitHub. The idea of debugging anything related to a segmentation fault in C seemed like a giant step backwards for a PHP developer. Most of us haven’t written anything in C since college, which at this point was double-digit years ago.
Phalcon is an interesting idea, and a logical step between a framework entirely written in PHP and making the switch to HHVM and Hack. The lack of a toolbar is definitely a show-stopper. Once a toolbar is included in Phalcon, I’ll definitely reconsider. It’s that fast.