Mac OS 下安装 Zephir 教程

因为某些原因需要自己开发PHP扩展,于是找到了Zephir 开发的方式,Zephir 是一种中间语言,以接近 PHP 的语法来编写代码,然后转换成 PHP 扩展。

  • 官方文档中几乎没有照顾到 Mac 用户,资料较少。
  • 与 Linux 相比,Mac 下缺少一些用于编译 C 代码的扩展,需要自己折腾。
brew install re2c

在按照文档链接进行编译的过程中呢,出现了一个小插曲,无法安装下图所示的内容 这个时候呢需要运行下  xcode-select --install 然后再重新编译即可





[Zephir Parser]
extension=/Applications/MxSrvs/bin/php/lib/php/extensions/no-debug-non-zts-20170718/zephir_parser.so
php -i|grep php.ini
php -m
 chmod 777 zephir.phar
 然后删除 zephir.phar  文件的  .phar
 执行效验命令  ./zephir   出现下面的内容就是安装成功啦  这个是在文件所在目录执行的奥 

_____ __ _
/__ / ___ ____ / /_ (_)____
/ / / _ \/ __ \/ __ \/ / ___/
/ /__/ __/ /_/ / / / / / /
/____/\___/ .___/_/ /_/_/_/
/_/

Zephir 0.12.4 by Andres Gutierrez and Serghei Iakovlev (b386980)

Usage:
command [options] [arguments]

Options:
--dumpversion Print the version of the compiler and don't do anything else
-h, --help Print this help message
--no-ansi Disable ANSI output
-V, --version Print compiler version information and quit

Available commands:
api Generates a HTML API based on the classes exposed in the extension
build Generates/Compiles/Installs a Zephir extension
clean Cleans any object files created by the extension
compile Compile a Zephir extension
fullclean Cleans any object files created by the extension (including files generated by phpize)
generate Generates C code from the Zephir code without compiling it
help Displays help for a command
init Initializes a Zephir extension
install Installs the extension in the extension directory (may require root password)
stubs Generates stubs that can be used in a PHP IDE

阅读剩余
THE END