Phalcon – a PHP Framework

phalcon250Well, it looks like I might be a tad late to the party, but late is better than not showing up at all.  There's a new party going on in the PHP world.  A revolution, if I might be so bold.  PHP is being turned on it ear, and all I can say so far is, WOW!

The new kid on the block is the Phalcon PHP framework.  Every once in a while an idea comes along in technology, and all you can say is why didn't we think of this earlier.  Phalcon is that idea.

Rasmus Lerdorf started the PHP language in 1994.  That's 20 years ago, 20 years can you believe it.  It is now used in over 244 million web sites, and 2.1 million servers.

Programmers like PHP, because unlike C and Java, they don't have to compile their code before seeing if their web programs work. It cuts out a step, but adds some complexity like having to check variable types before it can run. It's a language that is written in the C language, which is blindingly fast.  PHP is slower, because every time PHP opens a file it scans the PHP code, and then creates C byte code to run the program.  So PHP is slower than C.

What if we wrote a PHP framework as a C extension, so although you would use PHP like you normally would, the code that ran was C and would not have to be run through the PHP interpreter.  And what if we optimized the C code we wrote for speed.  Then that code would be blazingly fast, compared to any PHP code run through the interpreter.  Faster than any other PHP framework that came before it.

Let me introduce you to the Phalcon PHP framework.

Phalcon is a PHP framework that is written as a C extension to PHP.  The framework is an optimized, fully functional framework that is currently about 1.7Mb of code.  However, unlike any other PHP framework, it is an extension to the PHP language.  That means that you add the pre-compiled C code to your PHP /ext directory, and turn it on as an extension in your PHP.ini file, just like you do with curl, mysql, or sqlite extensions. That's it.

Normally to set up a PHP framework for use, you down load the code, set it up in its own directory structure.  Your application is then written inside that directory structure, usually in an application directory, with all the other core framework code in the other directories of the framework.  Any code written in the application directory is picked up by the framework core code, and runs the special functionality provided by that framework.

Phalcon uses the MVC architecture, like all the other frameworks, but unlike other frameworks, there is no set file structure you have to use to structure your application.  You can set up any directory structure you like.

How do you set up the application?  You create a bootstrap file that loads the autoloader, sets up the dependency container, turns on the error logger, and template engine, if you want to use it, and tells the application where your files are located, then you build your application using the Phalcon syntax and Phalcon takes care of the rest.

So how does Phalcon stack up. First and for most, Phalcon is hands down the fastest fully functional PHP framework in existence.  It's even faster than the mini-frameworks optimized for speed.  Phalcon shows up 2-10 times faster than any other framework out there.  The Phalcon developers knew they had something, but they didn't stop there.

Phalcon features include:

  • Loosely coupled, allowing you to use it as a component library
  • A built-in, fully functional ORM that outperforms all the other ORM's out there.
  • An ODM for document mapping for the NoSQL database fans
  • Dependency Injection/Service Location containers
  • Events and event management with listeners
  • A universal auto-loader that conforms to PSR-0
  • A router for navigation
  • Security with password hashing
  • Messages and error logging.
  • An integrated template engine, Volt
  • Form Builders, Pagination, and Validators
  • Multi-language support
  • Asset managerment for javascript and css libraries
  • Cache - do they even need it.

Phalcon's documentation is thorough, full of examples, and well written.  I think you'll find its easy to learn.

The development community has sprung to life around this framework.  There is an incubator for developers to submit their PHP code for possible inclusion into Phalcon.  There is a set of development tools, that will create stub code for controllers and models with all the getters and setters, much like Laravel's Artisan.  You can create stub code with a GUI, or the command line.

If you haven't taken a serious look at the Phalcon framework yet, I strongly recommend that you do.   I believe this framework has taken the PHP development community by storm, and will be around for quite awhile, it leaves all the other frameworks in the dust.

Comments

Phalcon – a PHP Framework — 1 Comment