PHALCON
PHALCON

PhalconPHP: An Introduction to the Fastest PHP Framework


The PHP community has grown in leaps and bounds. Several kingdoms( PHP Frameworks) have risen and fallen. My favorite: Laravel is the most popular and loved PHP framework and that’s what I use for all my production apps.

Introduction

Phalcon is an open source web framework delivered as a C extension for the PHP language providing high performance and lower resource consumption.

What sells PhalconPHP to the world is its speed!.

I have decided to start learning it and also compare it with Other PHP frameworks in terms of speed, fluency, ORM, templating engines, validation components, caching, pagination and the community involved.

Speed

Phalcon is built as a C extension hence making requests faster because it compiles everything out of the box. There are benchmarks that have been done on it against other frameworks and these are the results.

phalcon-01

Look at the difference in speed compared to other frameworks. Wow! Amazing!!!

ORM

Phalcon has its own ORM, Phalcon Query Language (PHQL), which can be used to make database interaction more expressive and clean. PHQL can be integrated with models to easily define and use relationships between your tables.

Models extends the PhalconMvcModel class just like Models extend the Eloquent Class in Laravel

Phone Model

Views

The Volt templating engine is highly integrated wth Phalcon components and it’s friendly and said to be superfast.

show.volt

You may register Volt in the view component, using a new extension or reusing the standard .phtml like so:

You can use the standard .phtml extension like so:

You can also pass variables to the view via the Controller.

Controllers

Controllers in Phalcon provide the initialize() that is run before any other function that the Controller has.

Controllers must extend the Phalcon Controller, have the suffix “Controller” while actions must have the suffix “Action”.

Rest API

It’s relatively easy to create a rest api service in Phalcon. In the index.php you can just create it like so:

Installation

I use a Mac and you need the follow requirements for OSX:

1. Xcode

2. PHP >= 5.4

You can run any of these commands on your terminal to add the phalcon framework as an extension to your PHP configuration.

Screen Shot 2015-10-02 at 3.53.04 PM

Now, Verify to see if it has been installed.

Log in to the PHP interactive shell like so:

Then from the shell, execute:

it lists all the php extensions you have on your system/server

Screen Shot 2015-10-02 at 3.55.08 PM

Phalcon is the 52nd extension present in my PHP configuration.

Restart your webserver and you can start using Phalcon just like that!. It’s part of your core PHP Classes loaded on your server/system. It’s that simple!!

Conclusion

I’ll be running a series of tutorials in building CRUD apps using Phalcon and also REST API services. I really love Laravel and I am an unofficial evangelist of the framework but it doesn’t hurt to expand your horizon on the knowledge of other PHP frameworks like Phalcon. Join me in this Journey!

Please if you have any questions or observations, feel free to drop it in the comments section.

 

PROSPER OTEMUYIWA

About PROSPER OTEMUYIWA

Food Ninja, Code Slinger, Technical Trainer, Accidental Writer, Open Source Advocate and Developer Evangelist.