- 下載原始碼
- 安裝
- ./configure --prefix=指定安裝路徑--with-config-file-path=指定配置檔案讀取路徑 --with-iconv=指定iconv安裝的路徑 --enable-debug
- make && make install
- 使用clion建立project
-
修改自動生成的CMakeLists.txt檔案, 注意原始碼路徑要根據情況調整
cmake_minimum_required(VERSION 3.14) project(php_7_2_4) set(CMAKE_CXX_STANDARD 14) set(PHP_SOURCE /usr/local/src/php-7.2.4) include_directories(${PHP_SOURCE}/main) include_directories(${PHP_SOURCE}/Zend) include_directories(${PHP_SOURCE}/sapi) include_directories(${PHP_SOURCE}/pear) include_directories(${PHP_SOURCE}/TSRM) include_directories(${PHP_SOURCE}) add_custom_target(makefile COMMAND make && make install WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
-
配置執行引數
-
在sapi/cli/php_cli.c檔案中找到main函式,打斷點
-
點選debug之後就可以進行除錯了
- iconv未安裝,安裝後提示“ld: symbol(s) not found for architecture x86_64”
- 解決方法:編輯專案根路徑下的Makefile,修改EXTRA_LIBS變數,刪除-liconv,新增/usr/local/opt/libiconv/lib/libiconv.dylib