標籤:strong configure 配置 .net phpize config 功能 設定檔 figure
第1步:
首先從官網下載了PHP源碼
http://am1.php.net/distributions/php-7.1.3.tar.bz2
第2步:
解壓後可以看到根目錄下面的ext檔案夾裡有ext_skel檔案,
這個ext_skel是shell檔案,是可以啟動並執行。
cd到ext檔案夾後,執行./ext_skel --extname=hello
就可以產生hello檔案夾了
第3步:
cd到hello檔案夾裡可以看到config.m4檔案,開啟找到這樣的代碼
dnl PHP_ARG_WITH(hello, for hello support,dnl Make sure that the comment is aligned:dnl [ --with-hello Include hello support])
把開頭的“dnl ”都去掉,也就是改成這樣
PHP_ARG_WITH(hello, for hello support,Make sure that the comment is aligned:[ --with-hello Include hello support])
這時候你的代碼就已經可以進行phpize、./configure、make install了,把hello.so檔案加到php.ini擴充裡就能用了。
你也就可以通過php hello.php來進行測試config.m4檔案是否配置正常了。
這3行代碼的作用是為了讓./configure時,能夠調用enable-sample選項的最低要求.
PHP_ARG_ENABLE的第二個參數將在./configure處理過程中,到達這個擴充的設定檔時顯示.
第三個參數將在終端使用者執行./configure --help時顯示為協助資訊
第4步:測試
其實做完前3步擴充就已經成功能用了,
下面簡單寫一個PHP代碼來測試吧。
PHP7.1擴充開發入門