-
从github 安装 zephir.phar 最新网址 https://github.com/zephir-lang/zephir/releases
-
将文件改名 zephir.phar 改名为 zephir 放到 /bin 目录下
-
查看是否安装
zephir help
-
安装 zephir_parser
pecl install zephir_parser
增加扩展到 php.ini .重新加载
extension=zephir_parser.so
-
执行 初始化
zephir init app // app为命名空间
-
进入 app 目录 有文件 config.json , ext 目录 , app 目录
-
写一个简单PHP 案例
namespace App; class MyClass { public static function sayHello() { return "Hello from Zephir!"; } }
-
执行build 打包 等待打包到ext 目录
zephir build
执行结果
Preparing for PHP compilation... Preparing configuration file... Compiling... Zephir version has changed, use "zephir fullclean" to perform a full clean of the project Installing... Extension installed. Add "extension=app.so" to your php.ini ! [NOTE] Don't forget to restart your web server
-
进入ext 执行install 安装到PHP 环境 so , 并重启PHP 服务
-
新建一个PHP文件
echo App\MyClass::sayHello();
-
正常显示 Hello from Zephir!
zephir 实现PHP封装成C语言扩展文件so实现demo简单案例【菜鸟级教程】
猜你喜欢
转载自blog.csdn.net/abc564643122/article/details/134765427
今日推荐
周排行