一、phalcon简介,phalcon框架是c实现的php扩展,是php语言中高性能的mvc框架,他的内容不仅是mvc,包含了很多好用的库,比如orm,crypt。另外还提供restful风格的api。
二、phalcon安装
1)前提是安装了php
2)下载安装 git clone git://github.com/phalcon/cphalcon.git
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
不出意外的话即可安装成功,会出现以下提示。
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
Installing header files: /usr/include/php/
Thanks for compiling Phalcon!
Build succeed: Please restart your web server to complete the installation
3)安装可能会遇到的问题,编译提示Cannot find autoconf,在Mac下直接通过brew install autoconf即可。
4)根据安装结果的提示,phalcon.so模块安装到了/usr/lib/php/extensions/no-debug-non-zts-20121212目录下,配置php.ini文件,将该扩展添加到文件中。
extension=phalcon.so,这样配置就可以了,也可以将phalcon.so的绝对路径填在这里。php.ini文件默认是没有的,但是php.ini.default文件是有的,在/etc目录下,可以拷贝php.ini.default文件为php.ini,然后配置。
三、验证安装,在phpinfo()下可以看到phalcon的扩展被显示出来。
四、安装phalcon工具,快速创建phalcon项目。
git clone git://github.com/phalcon/phalcon-devtools.git
cd phalcon-devtools
sudo ./phalcon.sh
安装提示如下,表示安装成功。
Phalcon Developer Tools Installer
Make sure phalcon.sh is in the same dir as phalcon.php
and that you are running this with sudo or as root.
Installing Devtools...
Working dir is: /Users/feiy/Public/phalcon-devtools
Generating symlink...
Done. Phalcon Developer Tools installed!
Thank you for using Phalcon Developer Tools!
We hope that Phalcon Developer Tools helps to make your life easier.
In case of problems: https://github.com/phalcon/phalcon-devtools/issues
and: https://forum.phalconphp.com
To start using Phalcon Developer Tools you need to run 'source /Users/feiy/.bash_profile'
Phalcon DevTools (3.2.0)
Available commands:
info (alias of: i)
commands (alias of: list, enumerate)
controller (alias of: create-controller)
module (alias of: create-module)
model (alias of: create-model)
all-models (alias of: create-all-models)
project (alias of: create-project)
scaffold (alias of: create-scaffold)
migration (alias of: create-migration)
webtools (alias of: create-webtools)
console (alias of: shell, psysh)
安装信息很明确,phalcon-devtool的环境变量已经设置到了~/.bash_profile文件当中了,需要运行 source ~/.bash_profile来生效。
运行source ~/.bash_profile之后,可以在命令行的任意目录下运行phalcon命令,比如:phalcon --version