PHP7.1擴充開發入門

來源:互聯網
上載者:User

標籤: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擴充開發入門

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.