Installation


    Phalcon v4 supports only PHP 7.2 and above. PHP 7.1 has been released 2 years ago and its active support has lapsed, so we decided to follow actively supported PHP versions.

    PSR

    Phalcon requires the PSR extension. The extension can be downloaded and compiled from this GitHub repository. Installation instructions are available on the of the repository. Once the extension has been compiled and is available in your system, you will need to load it to your php.ini. You will need to add this line:

    before

    1. extension=phalcon.so

    Alternatively some distributions add a number prefix on ini files. If that is the case, choose a high number for Phalcon (e.g. 50-phalcon.ini).

    PDO

    Since Phalcon is loosely coupled, it exposes functionality without the need for additional extensions. However certain components rely on additional extensions to work. When in need for database connectivity and access, you will need to install the php_pdo extension. If your RDBMS is MySQL/MariaDB or Aurora, you will need the php_mysqlnd extension also. Similarly, using a PostgreSql database with Phalcon requires the php_pgsql extension.

    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.

    We have hosted our website and blog for the last few years on an Amazon VM with 512MB RAM and 1 vCPU.

    Software

    Along with PHP 7.2 or greater, depending on your application needs and the Phalcon components you need, you might need to install the following extensions:

    For the libpcre3-dev package you can use the following commands:

    Debian

    1. sudo apt-get install libpcre3-dev

    and then try and install Phalcon again

    CentOS

    1. sudo yum install pcre-devel

    Mac/Osx using MacPorts

    Make sure you have installed and up to date (sudo port -v selfupdate)

    1. sudo port install php-phalcon4

    Mac/Osx using brew

    1. brew install pcre

    Without brew, you need to go to the website and download the latest pcre:

    1. tar -xzvf pcre-8.42.tar.gz
    2. cd pcre-8.42
    3. ./configure --prefix=/usr/local/pcre-8.42
    4. make
    5. make install
    6. ln -s /usr/local/pcre-8.42 /usr/sbin/pcre
    7. ln -s /usr/local/pcre-8.42/include/pcre.h /usr/include/pcre.h

    For Maverick

    1. brew install pcre

    if it gives you error, you can use

    1. sudo ln -s /opt/local/include/pcre.h /usr/include/
    2. sudo pecl install apc

    Installation Platforms

    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

    Mainline releases (alpha, beta etc.)

    1. curl -s https://packagecloud.io/install/repositories/phalcon/mainline/script.deb.sh | sudo bash
    Phalcon installation

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

    1. sudo apt-get update
    2. sudo apt-get install php7.2-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 .

    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

    Nightly releases

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

    Mainline releases (alpha, beta etc.)

    1. curl -s https://packagecloud.io/install/repositories/phalcon/mainline/script.rpm.sh | sudo bash
    Phalcon installation

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

    1. sudo yum update
    2. sudo yum install php72u-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 .

    Installing Phalcon after that is as easy as:

    1. yum install php72-php-phalcon4

    Additional versions are available both architecture specific (x86/x64) as well as PHP version specific

    FreeBSD

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

    pkg_add
    Source
    1. cd /usr/ports/www/phalcon
    2. make install clean
    Gentoo

    An overlay for installing Phalcon can be found here

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

    Requirements

    • PHP 7.2.x development resources
    • XCode

    Brew

    1. brew tap tigerstrikemedia/homebrew-phalconphp
    2. brew install php72-phalcon
    3. brew install php73-phalcon

    MacPorts

    1. sudo port install php72-phalcon
    2. sudo port install php73-phalcon
    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 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:

    The available DLLs are:

    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 7.2.x/7.3.x development resources
    • GCC compiler (Linux/Solaris/FreeBSD) or Xcode (macOS)
    • re2c >= 0.13
    • libpcre-dev

    Compilation

    Download the latest from . Add it to a folder that can be accessed by your system.

    Clone the repository

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

    Compile Phalcon

    1. cd cphalcon/
    2. git checkout tags/v4.0.0-alpha1 ./
    3. zephir fullclean
    4. zephir build

    Check the module

    1. php -m | grep phalcon

    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/php7/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/php7/apache2/conf.d/ with this content:
    6. extension=phalcon.so
    7. # Ubuntu/Debian with php7-fpm: Add a file called 30-phalcon.ini in /etc/php7/fpm/conf.d/ with this content:
    8. extension=phalcon.so
    9. # Ubuntu/Debian with php7-cli: Add a file called 30-phalcon.ini in /etc/php7/cli/conf.d/ with this content:
    10. extension=phalcon.so

    The instructions above will compile and install the module on your system. You can also compile the extension and then add it manually in your ini file:

    If you use the above method you will need to add the extension=phalcon.so in your php.ini both for CLI and web server.

    Tuning build

    By default we compile to be as compatible as possible with all processors (gcc -mtune=native -O2 -fomit-frame-pointer). If you would like instruct the compiler to generate optimized machine code that matches the processor where it is currently running on you can set your own compile flags by exporting CFLAGS before the build.For example

    1. zephir build

    This will generate the best possible code for that chipset but will likely break the compiled object on older chipsets.

    Running your application on shared hosting might restrict you in installing Phalcon, especially if you do not have root access. Some web hosting control panels luckly have Phalcon support.

    cPanel & WHM

    cPanel & WHM support Phalcon using Easy Apache 4 (EA4). You can install Phalcon by enabling the module in Easy Apache 4 (EA4).

    Plesk

    The plesk control panel doesn’t have Phalcon support but you can find installation instructions on the Plesk website