Windows 下的 PHP 擴充編程

來源:互聯網
上載者:User

    PHP 儘管提供了大量有用的函數,但是在特殊情況下還可能需要進行擴充編程,比如大量的 PECL(PHP Extension Community Library)就是以擴充的形式提供的(動態連結程式庫dll檔案),它們比 PEAR 的運行效率要高很多。
    PHP 擴充是用 C 或 C++ 編寫的,需要編譯成動態串連庫 dll 檔案後在 PHP 環境下註冊後才能使用。
    編寫 PHP 擴充的軟體要求:
      VC++6.0 或 VC++.NET 環境。
      PHP 的原始碼,需要編譯。
    如果不願意編譯 PHP 的原始碼,可以再下載 PHP 的已經編譯成功的二進位代碼(就是我們部署 PHP 運行環境的那些檔案包)。注意分別下載的源檔案包和已編譯包,它們的版本必須一致。

    過程:

    1,安裝 VC++6.0,並選擇把其可執行檔路徑加入環境變數中,使在命令列環境任意路徑下可以運行編譯器。
    2,安裝 PHP 運行環境,並與 IIS 正確整合在一起。假設使用的 PHP 版本為 5.2.5,下載 php-5.2.5-Win32.zip 二進位包和 php-5.2.5.tar.gz 原始碼包。安裝環境為 C:php-5.2.5-Win32。分別把原始碼包和二進位包解壓到該檔案夾下。從 php.ini-recommended 拷貝產生一個 php.ini 檔案。
    3,建立 C:php-5.2.5-Win32Release_TS 檔案夾,拷貝 C:php-5.2.5-Win32devphp5ts.lib 檔案到這裡。
    4,進入 C:php-5.2.5-Win32ext 檔案夾,運行命令:
      C:php-5.2.5-Win32ext>..php.exe ext_skel_win32.php --extname=myphpext
      Creating directory myphpext
      Creating basic files: config.m4 config.w32 .cvsignore myphpext.c php_myphpext.h
      CREDITS EXPERIMENTAL tests/001.phpt myphpext.php [done].

      To use your new extension, you will have to execute the following steps:

      1.  $ cd ..
      2.  $ vi ext/myphpext/config.m4
      3.  $ ./buildconf
      4.  $ ./configure --[with|enable]-myphpext
      5.  $ make
      6.  $ ./php -f ext/myphpext/myphpext.php
      7.  $ vi ext/myphpext/myphpext.c
      8.  $ make

      Repeat steps 3-6 until you are satisfied with ext/myphpext/config.m4 and
      step 6 confirms that your module is compiled into PHP. Then, start writing
      code and repeat the last two steps as often as necessary.

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.