版权声明:转载的时候提到我就行…… https://blog.csdn.net/SakuraLLj/article/details/77187186
生成扩展框架
执行php7源码/xxx/php-7.1.3/ext目录下的ext_skel命令,生成扩展框架
$ /xxx/php-7.1.3/ext/ext_skel --extname=ljtest //ljtest为扩展名
编译并把扩展加入php
$ cd ljtest
$ /usr/local/php-7.1.3/bin/phpize
$ ./configure --with-php-config=/usr/local/php-7.1.3/bin/php-config
$ make
$ sudo make install
把编译好的扩展加到php.ini中,用/usr/local/php-7.1.3/bin/php -m 看一下扩展是否按照
用clion导入扩展代码
编辑CMakeLists.txt
cmake_minimum_required(VERSION 3.7)
project(ljtest)
add_custom_target(makefile COMMAND make && sudo make install WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
注:编辑完后要重新reload一下
编辑 config.m4
按照提示把dnl注释去掉
dnl $Id$
dnl config.m4 for extension ljtest
dnl Comments in this file start with the string 'dnl'.
dnl Remove where necessary. This file will not work
dnl without editing.
dnl If your extension references something external, use with://如果需要使用第三方扩展就去掉下面的dnl注释
dnl PHP_ARG_WITH(ljtest, for ljtest support,
dnl Make sure that the comment is aligned:
dnl [ --with-ljtest Include ljtest support])
dnl Otherwise use enable://否则就去掉下面的注释
PHP_ARG_ENABLE(ljtest, whether to enable ljtest support,
Make sure that the comment is aligned:
[ --enable-ljtest Enable ljtest support])
配置clion
选择Edit Configurations
进入编辑页面
注:如果没有马克file选项,说明在配置完CMakeLists.txt时没有reload
点击run,如果出现下图就说明成功了
debug
打断点,按debug加入debug