PHP擴充套件 如何使用檔案config m4

2022-08-12 09:39:20 字數 1783 閱讀 9903

config.m4檔案用於指定正在開發的擴充套件在類unix系統下構建時支援的選項,指定此擴充套件需要哪些庫以及哪些原始檔;使用 gnu autoconf 語法編寫。

注意需要重新執行phpize,config.m4的修改才會生效;

在執行./configure時,所有的輸出將記錄到config.log裡,通過檢視此檔案可以除錯config.m4。

如何從零開始建立乙個php擴充套件可以參見文章php擴充套件-擴充套件的生成和編譯,

以下將以」myext」作為正在開發的擴充套件名稱進行舉例:

1. 由使用者輸入配置選項

比如–enable-myext, –with-myext-includedir=dir

php_arg_enable(myext, whether to enable myext support,

[ --enable-ext enable ext support])

在configure –help時將輸出:–enable-ext enable ext support

php_arg_with(myext-includedir, for

myext header,

[ --with-myext-includedir=dir myext header files], no, no)

在configure –help時將輸出:–with-myext-includedir=dir myext header files

2. 輸出資訊

ac_msg_checking(message), 在執行configure命令時輸出」checking 「;

ac_msg_result(value), 輸出check的結果;

ac_msg_error(message), 輸出一條訊息並退出configure的執行;

3. 新增包含路徑

php_add_include(path), 新增編譯時的包含路徑;

4. 鏈結第三方庫

php_add_library_with_path(),新增編譯時的鏈結庫路徑

php_add_library(), 新增鏈結庫;

5. 其他

ac_define(name,value,description), 向php_config.h新增乙個define:#define name value // description;

ac_try_compile (includes, function-body, [action-if-found [, action-if-not-found]])

示例如下:

...

ac_msg_checking(php version)

...ac_msg_result([$php_version])

...php_major_version=`echo $php_version | sed -e '

s/\([[0-9]]*\)\.\([[0-9]]*\)\.\([[0-9]]*\).*/ \1/g

'2>/dev/null

`if test $php_major_version -lt 5; then

ac_msg_error([need at least php

5or newer])

fi...

......

參考:talking to the unix build system: config.m4

nginx 如何使用 識別 多個conf配置檔案

macbook pro 使用brew安裝nginx 版本 nginx 1.15.9 其實這個答案網上很多,但是標題有點文不對題,讓我找了好一會。所以我再重新寫一遍。安裝好nginx之後,在 usr local etc nginx目錄下新建了conf.d資料夾 在其中新建了1個配置檔案,a.conf ...

如何使用Zephir輕鬆構建PHP擴充套件

比如,在 php 中需要與 sqlite3 互動,我們可以自己寫方法與之進行連線,再寫 sql 語句請求資料。然而,這都是些既瑣碎又重複度相當高的工作,因此,所有開發者對外掛程式的需求呼之欲出。現在,這款外掛程式已經誕生了。你只需像安裝其他擴充套件一樣進行安裝,然後在 php.ini 檔案執行 ex...

PHP使用 zip 擴充套件壓縮檔案

第乙個想法就是使用exec在linux進行打包。但是.exec方法吧,你懂得,我不太願意使用這個函式。於是上網查詢,結果就是,我低估了php對於io的操作,給我的教訓是,以後遇到什麼問題應該先考慮怎麼從 層面解決,如果不行再考慮其他的。安裝zip擴充套件的方法不多說,網上一搜一大片。這裡主要說它的簡...