江新宇

centos 6 下,zephir的安装和使用

zephir或许会开启一个新的PHP编写方式。 在这之前,如果我们要编写php的扩展,一般都是c++/clang/vc等等。 但是现在,我们有了新的选择: zephir.
zephir本身并不是为了替代c++/clang/vc等。 它本质是介于c和php的之间的一个语言,一个桥梁。

下面我们开始安装。 安装环境基于CentOS 6.5, php都是通过yum install安装。 而不是编译安装。
php版本信息:

PHP 5.5.7 (cli) (built: Dec 13 2013 15:59:26)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2013 Zend Technologies
with Zend OPcache v7.0.3-dev, Copyright (c) 1999-2013, by Zend Technologies
with Xdebug v2.2.3, Copyright (c) 2002-2013, by Derick Rethans

安装系统依赖:

 

yum install wget git autoconf automake libtool  gcc-c++
     
安装其他依赖的东西: json-c和re2c
json-c安装:
git clone https://github.com/json-c/json-c.git
cd json-c
./autogen.sh
./configure
make
make install

 

re2c安装:
现在最新的版本是:0.13.6

http://sourceforge.net/projects/re2c/files/re2c/0.13.6/

下载其中的tar.gz文件即可。 (不要下载.zip的文件)

cd ~
wget http://downloads.sourceforge.net/project/re2c/re2c/0.13.7.5/re2c-0.13.7.5.tar.gz
tar zxf re2c-0.13.7.5.tar.gz
cd re2c-0.13.7.5
./configure
make
make install

 

安装后,可执行文件re2c会放到/usr/local/bin, 把它链接到/usr/bin
cd /usr/bin
ln -s /usr/local/bin/re2c re2c

 

然后在任何地方执行re2c -v, 应该输出:
[root@QXDev2 ~]# re2c -v
re2c 0.13.6

 

好了,基本东西就绪, 那么我们开始进入整体: zephir的安装。
git clone https://github.com/phalcon/zephir.git
cp -R zephir /usr/local/zephir
cd /usr/local/zephir
./install

 

得到提示如下:

Parser statistics: 107 terminals, 85 nonterminals, 334 rules
689 states, 0 parser table entries, 0 conflicts

 

这样就表明正确了。
下面让我们在任何地方都可以使用zephir命令

cd ~
vi .bashrc
#在最后一行添加:
export PATH=$PATH:/usr/local/zephir/bin
#保存
source .bashrc
zephir help

 

这个时候应该可以看到:
_____              __    _
/__  /  ___  ____  / /_  (_)____
/ /  / _ \/ __ \/ __ \/ / ___/
/ /__/  __/ /_/ / / / / / />
/____/\___/ .___/_/ /_/_/_/
/_/

Zephir version 0.2.2a

Usage:
command [options]

Available commands:
generate            Generates C code from the Zephir code
full-clean          Cleans the generated object files in compilation
compile             Compile a Zephir extension
help                Displays this help
install             Installs the extension (requires root password)
init [namespace]    Initializes a Zephir extension
clean               Cleans the generated object files in compilation
version             Shows Zephir version

Options:
-fno-([a-z0-9\-]+)  Setting options to Compiler
-W([a-z0-9\-]+)     Setting warning options to Compiler

 

到此,我们的安装就结束了。
具体使用请查看后续文章。
 
zephir 英文文档站点:http://zephir-lang.com/types.html
posted @ 2015-04-20 15:50  新风宇宙-江新宇的博客  阅读(1691)  评论(0编辑  收藏  举报