Skip to content

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

Pattern

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
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | sudo bash

or

Nightly releases
curl -s https://packagecloud.io/install/repositories/phalcon/nightly/script.deb.sh | sudo bash

NOTE

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
sudo apt-get update
sudo apt-get install php5-phalcon

PHP 7
sudo apt-get update
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:

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

and Phalcon:

sudo apt-get install php-phalcon

RPM based distributions (CentOS, Fedora, etc.)

Repository installation

Add the repository to your distribution:

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

or

Nightly releases
curl -s https://packagecloud.io/install/repositories/phalcon/nightly/script.rpm.sh | sudo bash

NOTE

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
sudo yum update
sudo yum install php56u-phalcon

PHP 7
sudo yum update
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:

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

pkg_add -r phalcon

Source

export CFLAGS="-O2 --fvisibility=hidden"

cd /usr/ports/www/phalcon

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.

brew tap tigerstrikemedia/homebrew-phalconphp
brew install php56-phalcon
brew install php70-phalcon
brew install php71-phalcon
brew install php72-phalcon

MacPorts

sudo port install php55-phalcon
sudo port install php56-phalcon

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

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:

Architecture Version Type
x64 7.x Thread safe
x64 7.x Non Thread safe (NTS)
x86 7.x Thread safe
x86 7.x Non Thread safe (NTS)
x64 5.6 Thread safe
x64 5.6 Non Thread safe (NTS)
x86 5.6 Thread safe
x86 5.6 Non Thread safe (NTS)
x64 5.5 Thread safe
x64 5.5 Non Thread safe (NTS)
x86 5.5 Thread safe
x86 5.5 Non Thread safe (NTS)

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

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

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

Suse

sudo zypper install php5-devel gcc make

CentOS/Fedora/RHEL

sudo yum install php-devel pcre-devel gcc make

Compile Phalcon

We first need to clone Phalcon from the GitHub repository

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

and now build the extension

cd cphalcon/build
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.

# Suse: Add a file called phalcon.ini in /etc/php5/conf.d/ with this content:
extension=phalcon.so

# CentOS/RedHat/Fedora: Add a file called phalcon.ini in /etc/php.d/ with this content:
extension=phalcon.so

# Ubuntu/Debian with apache2: Add a file called 30-phalcon.ini in /etc/php5/apache2/conf.d/ with this content:
extension=phalcon.so

# Ubuntu/Debian with php5-fpm: Add a file called 30-phalcon.ini in /etc/php5/fpm/conf.d/ with this content:
extension=phalcon.so

# Ubuntu/Debian with php5-cli: Add a file called 30-phalcon.ini in /etc/php5/cli/conf.d/ with this content:
extension=phalcon.so

Advanced Compilation

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

cd cphalcon/build

# One of the following:
sudo ./install --arch 32bits
sudo ./install --arch 64bits
sudo ./install --arch safe

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

git clone https://github.com/phalcon/cphalcon
# cd cphalcon/build/php5/32bits
cd cphalcon/build/php5/64bits

# NOTE: for PHP 7 you have to use
# cd cphalcon/build/php7/32bits
# or
# cd cphalcon/build/php7/64bits

make clean
phpize --clean

export CFLAGS="-O2 --fvisibility=hidden"
./configure --enable-phalcon

make
make install

If you have specific php versions running:

git clone https://github.com/phalcon/cphalcon
# cd cphalcon/build/php5/32bits
cd cphalcon/build/php5/64bits

# NOTE: for PHP 7 you have to use
# cd cphalcon/build/php7/32bits
# or
# cd cphalcon/build/php7/64bits

make clean
/opt/php-5.6.15/bin/phpize --clean

export CFLAGS="-O2 --fvisibility=hidden"
./configure --with-php-config=/opt/php-5.6.15/bin/php-config --enable-phalcon

make
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:

<?php

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:

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

This will output something similar to this:

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

You can also see the modules installed using the CLI:

php -m

Pattern

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.