1 Star 0 Fork 4

lineCode / zephir-framework

forked from Tinywan / zephir-framework 
Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

zephir-framework

使用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

  • 安装PHP7

  • 安装zephir

    sudo apt-get install php7.1-dev gcc make re2c autoconf
    git clone https://github.com/phalcon/zephir.git
    cd zephir
    sudo ./install -c
  • 安装php-zephir-parser

    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

      • PHP 文件加密 Zend Guard Loader

  • 4、重启php-fpm服务,查看扩展是否安装成功

    • Markdown

    • /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

      注:Zephirphp-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,否则没发编译。

创建和检查授权脚本

文档

Comments ( 0 )

Sign in for post a comment

About

使用 zephir 给 PHP7 写动态链接库 spread retract
Cancel

Releases

No release

Contributors

All

Activities

load more
can not load any more
PHP
1
https://gitee.com/lineco/zephir-framework.git
git@gitee.com:lineco/zephir-framework.git
lineco
zephir-framework
zephir-framework
master

Search

103611 48b8ff67 1899542 103622 4d02230c 1899542