Requirements

Phalcon needs PHP to run. Its loosely coupled design allows developers to install Phalcon and use its functionality without additional extensions. Certain components have dependencies to other extensions. For instance using database connectivity will require the php_pdo extension. If your RDBMS is MySql/MariaDb or Aurora databases you will need the php_mysqlnd extension also. Similarly, using a PostgreSql database with Phalcon requires the php_pgsql extension.

Hardware

Phalcon is designed to use as little resources as possible, while offering high performance. Although we have tested Phalcon in various low end environments, (such as 0.25GB RAM, 0.5 CPU), the hardware that you will choose will depend on the your application needs.

Our website and blog (as well as other sites) are hosted on an Amazon VM with 512MB RAM and 1 vCPU.

Software

  • PHP >= 5.5
You should always try and use the latest version of Phalcon and PHP as both address bugs, security enhancements as well as performance. PHP 5.5 will be deprecated in the near future, and Phalcon 4 will only support PHP 7

Phalcon need the following extensions to run (minimal):

  • curl
  • gettext
  • gd2 (to use the Phalcon\Image\Adapter\Gd class)
  • libpcre3-dev (Debian/Ubuntu), pcre-devel (CentOS), pcre (macOS)
  • json
  • mbstring
  • pdo_*
  • fileinfo
  • openssl

Optional depending on the needs of your application

Installation

Since Phalcon is compiled as a PHP extension, its installation is somewhat different than any other traditional PHP framework. Phalcon needs to be installed and loaded as a module on your web server.

Linux

To install Phalcon on Linux, you will need to add our repository in your distribution and then install it.

DEB based distributions (Debian, Ubuntu, etc.)

Repository installation

Add the repository to your distribution:

Stable releases
  1. curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash

or

Nightly releases
  1. curl -s https://packagecloud.io/install/repositories/phalcon/nightly/script.deb.sh | sudo bash
This only needs to be done only once, unless your distribution changes or you want to switch from stable to nightly builds.

Phalcon installation

To install Phalcon you need to issue the following commands in your terminal:

PHP 5.x
  1. sudo apt-get update
  2. sudo apt-get install php5-phalcon

PHP 7
  1. sudo apt-get update
  2. sudo apt-get install php7.0-phalcon

Additional PPAs

Ondřej Surý

If you do not wish to use our repository at packagecloud.io, you can always use the one offered by Ondřej Surý.

Installation of the repo:

  1. sudo add-apt-repository ppa:ondrej/php
  2. sudo apt-get update

and Phalcon:

  1. sudo apt-get install php-phalcon

RPM based distributions (CentOS, Fedora, etc.)

Repository installation

Add the repository to your distribution:

Stable releases
  1. curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.rpm.sh | sudo bash

or

Nightly releases
  1. curl -s https://packagecloud.io/install/repositories/phalcon/nightly/script.rpm.sh | sudo bash
This only needs to be done only once, unless your distribution changes or you want to switch from stable to nightly builds.

Phalcon installation

To install Phalcon you need to issue the following commands in your terminal:

PHP 5.x
  1. sudo yum update
  2. sudo yum install php56u-phalcon

PHP 7
  1. sudo yum update
  2. sudo yum install php70u-phalcon

Additional RPMs

Remi

Remi Collet maintains an excellent repository for RPM based installations. You can find instructions on how to enable it for your distribution here.

Installing Phalcon after that is as easy as:

  1. yum install php56-php-phalcon3

Additional versions are available both architecture specific (x86/x64) as well as PHP specific (5.5, 5.6, 7.x)

FreeBSD

A port is available for FreeBSD. To install it you will need to issue the following commands:

pkg_add

  1. pkg_add -r phalcon

Source

  1. export CFLAGS="-O2 --fvisibility=hidden"
  2. cd /usr/ports/www/phalcon
  3. make install clean

Gentoo

An overlay for installing Phalcon can be found here https://github.com/smoke/phalcon-gentoo-overlay

macOS

On a macOS system you can compile and install the extension with brew, macports or the source code:

Requirements

  • PHP 5.5.x/5.6.x/7.0.x/7.1.x development resources
  • XCode

Brew

As the homebrew/php tap has been deprecated and is in the process of being removed, A custom repository for Phalcon has been created.

PHP 5.5 has not been ported to homebrew/core and as such no longer exists. PHP 7.2 on the other hand has been added.

  1. brew tap tigerstrikemedia/homebrew-phalconphp
  2. brew install php56-phalcon
  3. brew install php70-phalcon
  4. brew install php71-phalcon
  5. brew install php72-phalcon

MacPorts

  1. sudo port install php55-phalcon
  2. sudo port install php56-phalcon

Edit your php.ini file and then append at the end:

  1. extension=php_phalcon.so

Restart your webserver.

Windows

To use Phalcon on Windows, you will need to install the phalcon.dll. We have compiled several DLLs depending on the target platform. The DLLs can be found in our download page.

Identify your PHP installation as well as architecture. If you download the wrong DLL, Phalcon will not work. phpinfo() contains this information. In the example below, we will need the NTS version of the DLL:

phpinfo

The available DLLs are:

ArchitectureVersionType
x647.xThread safe
x647.xNon Thread safe (NTS)
x867.xThread safe
x867.xNon Thread safe (NTS)
x645.6Thread safe
x645.6Non Thread safe (NTS)
x865.6Thread safe
x865.6Non Thread safe (NTS)
x645.5Thread safe
x645.5Non Thread safe (NTS)
x865.5Thread safe
x865.5Non Thread safe (NTS)

Edit your php.ini file and then append at the end:

  1. extension=php_phalcon.dll

Restart your webserver.

Compile from Sources

Compiling from source is similar to most environments (Linux/macOS).

Requirements

  • PHP 5.5.x/5.6.x/7.0.x/7.1.x development resources
  • GCC compiler (Linux/Solaris/FreeBSD) or Xcode (macOS)
  • re2c >= 0.13
  • libpcre-dev
    You can install these packages in your system with the relevant package manager. Instructions for popular linux distributions are below:

Ubuntu

  1. sudo apt-get install php5-dev libpcre3-dev gcc make

Suse

  1. sudo zypper install php5-devel gcc make

CentOS/Fedora/RHEL

  1. sudo yum install php-devel pcre-devel gcc make

Compile Phalcon

We first need to clone Phalcon from the Github repository

  1. git clone https://github.com/phalcon/cphalcon

and now build the extension

  1. cd cphalcon/build
  2. sudo ./install

You will now need to add extension=phalcon.so to your PHP ini and restart your web server, so as to load the extension.

  1. # Suse: Add a file called phalcon.ini in /etc/php5/conf.d/ with this content:
  2. extension=phalcon.so
  3. # CentOS/RedHat/Fedora: Add a file called phalcon.ini in /etc/php.d/ with this content:
  4. extension=phalcon.so
  5. # Ubuntu/Debian with apache2: Add a file called 30-phalcon.ini in /etc/php5/apache2/conf.d/ with this content:
  6. extension=phalcon.so
  7. # Ubuntu/Debian with php5-fpm: Add a file called 30-phalcon.ini in /etc/php5/fpm/conf.d/ with this content:
  8. extension=phalcon.so
  9. # Ubuntu/Debian with php5-cli: Add a file called 30-phalcon.ini in /etc/php5/cli/conf.d/ with this content:
  10. extension=phalcon.so

Advanced Compilation

Phalcon automatically detects your architecture, however, you can force the compilation for a specific architecture:

  1. cd cphalcon/build
  2. # One of the following:
  3. sudo ./install --arch 32bits
  4. sudo ./install --arch 64bits
  5. sudo ./install --arch safe

If the automatic installer fails you can build the extension manually:

  1. git clone https://github.com/phalcon/cphalcon
  2. # cd cphalcon/build/php5/32bits
  3. cd cphalcon/build/php5/64bits
  4. # NOTE: for PHP 7 you have to use
  5. # cd cphalcon/build/php7/32bits
  6. # or
  7. # cd cphalcon/build/php7/64bits
  8. make clean
  9. phpize --clean
  10. export CFLAGS="-O2 --fvisibility=hidden"
  11. ./configure --enable-phalcon
  12. make
  13. make install

If you have specific php versions running:

  1. git clone https://github.com/phalcon/cphalcon
  2. # cd cphalcon/build/php5/32bits
  3. cd cphalcon/build/php5/64bits
  4. # NOTE: for PHP 7 you have to use
  5. # cd cphalcon/build/php7/32bits
  6. # or
  7. # cd cphalcon/build/php7/64bits
  8. make clean
  9. /opt/php-5.6.15/bin/phpize --clean
  10. export CFLAGS="-O2 --fvisibility=hidden"
  11. ./configure --with-php-config=/opt/php-5.6.15/bin/php-config --enable-phalcon
  12. make
  13. make install

You will now need to add extension=phalcon.so to your PHP ini and restart your web server, so as to load the extension.

You can create a small script in your web server root that has the following in it:

  1. <?php
  2. phpinfo();

and load it on your web browser. There should be a section for Phalcon. If there is not, make sure that your extension has been compiled properly, that you made the necessary changes to your php.ini and also that you have restarted your web server.

You can also check your installation from the command line:

  1. php -r 'print_r(get_loaded_extensions());'

This will output something similar to this:

  1. Array
  2. (
  3. [0] => Core
  4. [1] => libxml
  5. [2] => filter
  6. [3] => SPL
  7. [4] => standard
  8. [5] => phalcon
  9. [6] => pdo_mysql
  10. )

You can also see the modules installed using the CLI:

  1. php -m
Note that in some Linux based systems, you might need to change two php.ini files, one for your web server (Apache/Nginx), and one for the CLI. If Phalcon is loaded only for say the web server, you will need to locate the CLI php.ini and make the necessary additions for the module to be loaded.