1. 程式人生 > >clion開發除錯php7擴充套件

clion開發除錯php7擴充套件

生成擴充套件框架

執行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
這裡寫圖片描述