This action will force synchronization from Tinywan/zephir-framework, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
使用Zephir给PHP写扩展
.
├── zephirlib -- 扩展库目录
│ ├── Auth
│ │ └── License.zep -- 权限认证
│ ├── Base
│ │ ├── AbstractModule.zep -- 模块抽象类
│ │ ├── Base.zep
│ │ └── Service.zep
│ ├── Db
│ │ └── Mysql.zep
│ └── Module -- 业务模块目录
│ ├── Category.zep
│ └── Edit.zep
├── config.json -- 编译扩展配置文件
└── ext -- 编译生成的.so文件
(重要)检查当前服务器的 re2c
版本,必须:re2c >= 0.13.6
sudo apt-get install php7.1-dev gcc make re2c autoconf
git clone https://github.com/phalcon/zephir.git
cd zephir
sudo ./install -c
git clone git://github.com/phalcon/php-zephir-parser.git
cd php-zephir-parser
// 最好指定配置文件位置,当然也可以直接做一个软连接
sudo ./install --phpize /usr/local/php-7.1.9/bin/phpize --php-config /usr/local/php-7.1.9/bin/php-config
修改PHP.ini配置文件
$ sudo find / -name zephir_parser.so
/usr/local/php-7.1.9/lib/php/extensions/no-debug-non-zts-20160303/zephir_parser.so
vim /usr/local/php-7.1.9/etc/php.ini
//添加以下内容
[Zephir Parser]
extension=zephir_parser.so
//重启服务器
sudo service php-fpm restart
配置检查
1、下载:
git clone https://github.com/Tinywan/zephir-framework.git
2、编译:
cd zephir-framework/zephirlib
zephir build
Compiling...
Installing...
Extension installed!
Add extension=zephirlib.so to your php.ini
Don't forget to restart your web server
3、添加扩展到php.ini
:
PHP 7
配置文件
vim /usr/local/php-7.1.9/etc/php.ini
# 添加内容
extension=/usr/lib/php/20160303/zephirlib.so
重启服务器:sudo service php7-fpm restart
PHP 5
配置文件
Installing shared extensions: /usr/lib/php5/20121212/
Cleaning..
cd /usr/lib/php5/20121212/
sudo vim /etc/php5/mods-available/zephirlib.ini
# 添加内容
extension=zephirlib.so
切换到目录/etc/php5/fpm/conf.d
做一个软连接
ln -s ../../mods-available/zephirlib.ini 20-zephirlib.ini
重启服务器:sudo service php5-fpm restart
4、重启php-fpm
服务,查看扩展是否安装成功
/etc/php5/fpm/conf.d/20-zephirlib.ini
编译错误
root@iZ235mi4a64Z:~/zephir-framework/zephirlib# zephir build
────────────────────────────────────────────────────────────
The Zephir Parser extension is not loaded.
Note: Zephir no longer distributed with internal parser.
To install latest stable Zephir Parser please refer to:
https://github.com/phalcon/php-zephir-parser
────────────────────────────────────────────────────────────
如何解决,查看命令行(cli)
的配置文件,添加zephir_parser
扩展
$ php --ini
Configuration File (php.ini) Path: /etc/php/7.1/cli
Loaded Configuration File: /etc/php/7.1/cli/php.ini
Scan for additional .ini files in: /etc/php/7.1/cli/conf.d
...
vim /etc/php/7.1/cli/php.ini
//添加以下内容
[Zephir Parser]
extension=/usr/local/php-7.1.9/lib/php/extensions/no-debug-non-zts-20160303/zephir_parser.so
$ php -m | grep Zephir
Zephir Parser
re2c 版本过低,导致php-zephir-parser
安装失败
安装 re2c 执行:sudo apt-get install re2c
Ubuntu 14.04 LTS
系统默认安装
安装php-zephir-parser
错误
sudo ./install
error: minimal required version of re2c is 0.13.6
查看当前版本
www@:~$ re2c --version
re2c 0.13.5
注:
Zephir
和php-zephir-parser
要求:re2c >= 0.13.6
下载安装最新版本
wget https://github.com/skvadrik/re2c/releases/download/0.16/re2c-0.16.tar.gz
tar zxvf re2c-0.16.tar.gz
cd re2c-0.16
./configure
make
make install
www@:~/tinywan/re2c-0.16$ re2c --version
re2c 0.16
注意:服务器系统内存不能小于:
512M
,否则没发编译。
Sign in for post a comment
Comments ( 0 )