安装

PHP框架的安装和普通php编写的框架或者是库有些不同,我们可以直接下载编译好的扩展或者从源码编译安装。

PHP extensions require a slightly different installation method to a traditional php-based library or framework. You can either download a binary package for the system of your choice or build it from the sources.

Windows

在Windows安装Phalcon 我们需要下载 phalcon dll库,然后编辑php.ini 在最后添加以下代码

To use phalcon on Windows you can download a DLL library. Edit your php.ini file and then append at the end:

  1. extension=php_phalcon.dll

重启web服务

Restart your webserver.

下面的视频演示了在windows平台如何一步步安装phalcon (国外的视频,需要翻墙)

The following screencast is a step-by-step guide to install Phalcon on Windows:

如果不知道该下载哪个DLL,可以参考下面的教程。

If you don’t know what DLL to download, use the following script to figure it out.

相关教程

Linux/Solaris

在Linux/Solaris平台可以通过下载编译源码轻松安装。

On a Linux/Solaris system you can easily compile and install the extension from the source code:

系统要求

基础要求环境

Prerequisite packages are:

  • PHP >= 5.3 development resources
  • GCC compiler (Linux/Solaris)
  • Git (if not already installed in your system - unless you download the package from GitHub and upload it on your server via FTP/SFTP)

其他平台需要的特定包

Specific packages for common platforms:

  1. #Ubuntu
  2. sudo apt-get install php5-dev libpcre3-dev gcc make php5-mysql
  3. # Suse
  4. sudo yast -i gcc make autoconf2.13 php5-devel php5-pear php5-mysql
  5. # CentOS/RedHat/Fedora
  6. sudo yum install php-devel pcre-devel gcc make
  7. # Solaris
  8. pkg install gcc-45 php-53 apache-php53

编译

创建扩展

Creating the extension:

  1. git clone --depth=1 git://github.com/phalcon/cphalcon.git
  2. cd cphalcon/build
  3. sudo ./install

添加扩展到php配置

Add extension to your php configuration:

  1. # Suse: Add this line in your php.ini
  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: Add a file called 30-phalcon.ini in /etc/php5/conf.d/ with this content:
  6. extension=phalcon.so
  7. # Debian with php5-fpm: Add a file called 30-phalcon.ini in /etc/php5/fpm/conf.d/30-phalcon.ini with this content:
  8. extension=phalcon.so

重启web服务

Restart the webserver.

如果运行debian php5-fpm 重启下它

If you are running Debian with php5-fpm, restart it:

  1. sudo service php5-fpm restart

phalcon可以自动识别所在的平台,我们可以强制为其他平台编译。

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

  1. cd cphalon/build
  2. sudo ./install 32bits
  3. sudo ./install 64bits
  4. sudo ./install safe

如果自动安装失败了,可以尝试手动编辑扩展。

If the automatic installer fails try building the extension manually:

  1. cd cphalcon/build/64bits
  2. export CFLAGS="-O2 --fvisibility=hidden"
  3. ./configure --enable-phalcon
  4. make && sudo make install

Mac OS X

On a Mac OS X system you can compile and install the extension from the source code:

系统要求

Prerequisite packages are:

  • PHP >= 5.4 development resources
  • XCode
  1. # brew
  2. brew tap homebrew/homebrew-php
  3. brew install php54-phalcon
  4. brew install php55-phalcon
  5. brew install php56-phalcon
  6. # MacPorts
  7. sudo port install php54-phalcon
  8. sudo port install php55-phalcon
  9. sudo port install php56-phalcon

添加扩展到php配置

Add extension to your php configuration:

FreeBSD

A port is available for FreeBSD. Just only need these simple line commands to install it:

  1. pkg_add -r phalcon

or

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

Installation Notes

Installation notes for Web Servers: