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 thePhalcon\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¶
- PDO Extension as well as the relevant RDBMS specific extension (i.e. MySQL, PostgreSql etc.)
- OpenSSL Extension
- Mbstring Extension
- Memcache, Memcached or other relevant cache adapters depending on your usage of cache
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¶
or
Nightly releases¶
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¶
PHP 7¶
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:
and Phalcon:
RPM based distributions (CentOS, Fedora, etc.)¶
Repository installation¶
Add the repository to your distribution:
Stable releases¶
or
Nightly releases¶
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¶
PHP 7¶
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:
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
¶
Source¶
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¶
Edit your php.ini file and then append at the end:
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:
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:
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¶
Suse¶
CentOS/Fedora/RHEL¶
Compile Phalcon¶
We first need to clone Phalcon from the GitHub repository
and now build the extension
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:
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:
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:
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.