What is Phalcon?

Phalcon is not only a framework, it is a PHP5 extension written in ‘C’ language. But you do not need to learn or use the ‘C’ language. Phalcon is loosely coupled, allowing you to use it’s objects as a components based on your application needs.

What is framework?

A software framework is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate development of software applications, products and solutions. Frameworks offer a     structured philosophy to easily maintain projects writing less code and making work more fun.

Why Phalcon?

There are lots of PHP frameworks now a days. Almost all programmers prefer to use frameworks. Most of the functionality is already considered and tested in frameworks.

Internal working of PHP:

We all know that PHP is an interpreted language and not a compiled language. Every time a script is requested, it must be first interpreted. Syntax checking is performed every time for every file in the request. The major disadvantage is performance loss.

How other PHP frameworks work?

  • Many files, classes and functions are read every time request made.
  • Disk reading is expensive in terms of performance, especially when the file structure also includes deep folders.
  • Modern frame use lazy loading to increase performance, to handle the load and execute only the required code.
  • Some of these classes contain methods that aren’t used in every request but they are still loaded consuming memory.

How Phalcon works?

  • Phalcon loads together with PHP one time on the web server’s daemon start process.
  • Phalcon framework code isn’t interpreted because is already compiled to a specific platform and processor
  • There is no restriction while using Phalcon framework. You are free to use full framework or a single part of framework.
  • Interact with databases with maximum performance by using a C-language ORM for PHP.

How to setup Phalcon with Apache on Windows and Linux?

Window Environment:

First lets look into the Phalcon setup on Windows environment. It is very easy to setup Phalcon on the Windows environment. The only drawback is that you need to choose the right .dll file for your environment.

Here is the URL from which you can access all the Phalcon dll files:


Now how to choose right Phalcon DLL file to download for your environment?

It’s very simple. Write a simple phpinfo file and check the PHP environment.

Following is the sample Code for : phpinfo.php file.


After executing the above file in your browser, you will get the PHP environment details. Here is the sample screen from the beginning containing the information details.

PHP environment details All about Phalcon: Part 1

There are three factors involved while choosing the .dll file for download.

1. PHP version.

2. 2. Architecture.

3. 3. Compiler

In the above screen, the PHP version is 5.5.9, The Architecture is x86 and finally the Compiler is MSVC11 which is nothing but VC11. It might happen that you will not get the right file for your current PHP version, in that case you can choose the immediate lower version of the PHP and search for the dll files.

Syntax :

Phalcon 1.3.4 – Windows for PHP ()

Example :

Phalcon 1.3.4 – Windows x86 for PHP 5.5.0 (VC11)

Download the dll zip file and extract the file.

Step 1 – Copy the file php_phalcon.dll to the PHP extensions. If you have installed XAMPP in the c:\xampp folder, the extension needs to be in c:\xampp\php\ext

Step 2 – Edit the php.ini file, it is located at C:\xampp\php\php.ini. It can be edited with Notepad or a similar program. We recommend Notepad++ to avoid issues with line endings. Append at the end of the file: extension=php_phalcon.dll and save it.

Step 3 – Restart the Apache Web Server.

To validate whether Phalcon is up and installed successfully, again execute the phpinfo.php file in your browser and search for Phalcon. You may see the following screenshots.

Phalcon All about Phalcon: Part 1

Linux Environment:

Again, it is extremely easy to install Phalcon on the Linux environment.


You need following packages previously installed.

1. PHP 5.x development resources.

2. GCC Compiler.

Following are the commands as per O.S. to install the required packages.


sudo apt-get install php5-dev php5-mysql gcc libpcre3-dev


sudo yum install php-devel php-mysqlnd gcc libtool


sudo yum install php-devel php-mysql gcc libtool


yast2 -i php5-pear php5-devel php5-mysql gcc

#OS X (Using Homebrew)

brew tap homebrew/dupes

brew tap homebrew/versions

brew tap homebrew/php

brew install php5x php5x-phalcon # Where “x” – minor number of PHP

First way to install Phalcon:

If you want to install Phalcon from the Ubuntu repository, here are three simple steps to install Phalcon:

1. sudo apt-add-repository ppa:phalcon/stable

2. sudo apt-get update

3. sudo apt-get install php5-phalcon

If you are missing the apt-add-repository run the following command:

sudo apt-get install python-software-properties

Compilation/Second way to install Phalcon (Preferred):

1. To create the extension from C source follow these steps:

git clone –depth=1 git://github.com/phalcon/cphalcon.git

cd cphalcon/build

sudo ./install

2. Add the extension to your php.ini:


3. Finally, restart the webserver

In compilation way we need to add the phalcon.ini file in the extension. How to create the ini file and where to keep the ini file is explained below:

After adding the extension in php.ini file, we need to create the ini file for Phalcon.

1. Check your extension directory & ini files directory

You might have found the following paths.

Extention dir path is : /usr/lib/php5/20121212

Ini files dir path is : /etc/php5/mods-available/

Now we need to go to the ini files dir path as like follow.

cd /etc/php5/mods-available/

Create a ini file there for Phalcon.

We have to create the file using other ini file.

You can use the following command.

sudo cp curl.ini phalcon.ini

Now we need to add/ modify the following line in the phalcon.ini file extension=/usr/lib/php5/20121212/phalcon.so

Again restart the Apache server.

sudo service apache2 restart

Check your phpinfo(). Phalcon is enabled there or it is not there. If you don’t find Phalcon, Execute the following command:

sudo ln -s /etc/php5/mods-available/phalcon.ini /etc/php5/apache2/conf.d/20-phalcon.ini

Above command creates the link of the phalcon.ini file.

Advantages and disadvantages of phalcon?

Sr. No. Advantages Disadvantages
1 Phalcon is an extension of PHP written in “C” language. You cannot deploy Phalcon project on shared hosting.
2 Framework code is already compiled. It is not a CMS with default login and registration functionality.
3 Request per second ratio much higher than other PHP frameworks. No Official IDE Support.
4 Performance of Phalcon is much higher than other PHP frameworks. No Multiversion support.

How to install phalcon developer tools.

There are two ways to install Phalcon developer tools.

1. Using composer.

Install composer in a common location or in your project:

curl -s http://getcomposer.org/installer | php

Create the composer.json file as follows:

  "require": {
      "phalcon/devtools": "dev-master"

Run the composer installer:

php composer.phar install

Create a symbolic link to the phalcon.php script:

ln -s ~/devtools/phalcon.php /usr/local/bin/phalcon

chmod ugo+x /usr/bin/phalcon

2. Manual installation.

sudo git clone git://github.com/phalcon/phalcon-devtools.git phalcondevtool

cd phacondevtool

sudo sh ./phalcon.sh

ln -s ~/phacondevtool/phalcon /usr/local/bin/phalcon

chmod ugo+x /usr/local/bin/phalcon

More in the next part



By |December 11th, 2014|Technology|0 Comments

About the Author:

 All about Phalcon: Part 1
Kunal Pingalkar has a total experience of 9 years with expertise in PHP, Ruby on Rails, MySQL, PgSL. Currently, he is working with PHP and Ruby on Rails. He came into the industry after completing his MS in Software Systems. Apart from computers, travelling and reading about tech trends interest him.

This entry passed through the Full-Text RSS service – if this is your content and you’re reading it on someone else’s site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers.
Want something else to read? How about ‘Grievous Censorship’ By The Guardian: Israel, Gaza And The Termination Of Nafeez Ahmed’s Blog

e-Zest | India | USA | UK | Germany | Europe