Build PHP Binary from Source: Step 2 – with PECL extensions

PECL (PHP Extension Community Library) is conceptually very similar to PEAR. PECL contains C extensions for compiling into PHP. As C programs, PECL extensions run more efficiently than PEAR packages. If you follow the following procedure, you can build PECL extensions together with the PHP binary package.

I. Prerequisite: You must finish the Build PHP Binary with the default modules successfully.

II. Download the PECL source code:

  1. My example is trying to compile the xdebug and APC extensions.
    1. xdebug: Download it at http://pecl.php.net/package/xdebug
    2. APC: Download it at http://pecl.php.net/package/APC
  2. Unzip the downloaded zip files and put them under C:\php-sdk\php54dev\vc9\x86\pecl. They will look like the following screenshots:

III. Compile:

  1. Set the environment: Open the “Windows SDK 6.1 Shell” (it’s available from the start menu group) and execute the following commands in it. If you are using 64 bit system, don't try to change the parameter to /x64, otherwise during the make period, you will see tons of WARNING.
    set PATH=D:\php-sdk\bin;%PATH%
    setenv /x86 /xp /release
    cd c:\php-sdk\
    bin\phpsdk_setvars.bat

    You will get the following screen:
  2. Build the configuration file for creating the make file:
    cd C:\php-sdk\php54dev\vc9\x86\php-5.4.5-src
    buildconf

    If you get an error like:
    Input Error: There is no script engine for file extension ".js".


    You need to edit the buildconf.bat file as below:

    Run the buildconf again:
    buildconf

    You will get the following screen:

    A new configuration file: configure.js will be created as below:

    Now, you can check the configuration options:
    configure --help

    If you get the following error again:
    Input Error: There is no script engine for file extension ".js".

    Please edit the configure.bat file and add /e:jscript after the /nologo.

    Run the configure --help again:
    configure --help

    If you installed the Cygwin, you can use the following commands to check if the APC and xdebug are included in the configuration file:
    configure --help | grep apc
    configure --help | grep xdebug

    If the APC and xdebug are included, you will see the following screen:
  3. Create the make file:
    configure --disable-snapshot-build --disable-debug-pack --disable-ipv6 --disable-zts --disable-isapi --disable-nsapi --without-t1lib --without-mssql --without-pdo-mssql --without-pi3web --without-enchant --enable-com-dotnet --with-mcrypt=static --disable-static-analyze --with-xdebug=shared --enable-apc

    If you run it successfully, you will see the screen as below. Pls check if the apc and xdebug extensions are included:
  4. Make the binary package by typing nmake:
    nmake

    Wait for a while, if you see this result, you succeeded.

    You will also find a new "Release" directory appeared under C:\php-sdk\php54dev\vc9\x86\php-5.4.5-src as below. If you see the php_xdebug.dll, it means the xdebug DLL has been created.

    Check the module:
    C:\php-sdk\php54dev\vc9\x86\php-5.4.5-src\Release\php.exe -m

    If you can see the apc in the screen as below, it means the apc module was compiled successfully in the PHP binary:

Congratulations! You are all done!

标签: PHP, SDK, MSVC9, PECL, extension, apc, xdebug

已有 12 条评论

  1. Your blog inspires me every time when I read it. I love reading blogs. I don't excite always by reading blog posts. But in your blog I find something that implies in blogging. Anyway, you are unquestionably a great blogger and you have a skill to make your reader to keep reading your blog again and again. Keep up the magnificent work.

  2. There is such a great amount in this article I would never have considered all alone. Your substance gives perusers things to consider in a fascinating way. Much obliged to you for your reasonable data

  3. I got what you mean , thanks for posting .Woh I am happy to find this website through google.Cheap poe currency

  4. This is such an awesome asset, to the point that you are giving and you give it away for nothing.our article has piqued a lot of positive interest.

  5. Totally incredible posting! Heaps of valuable data and motivation, both of which we all need!Relay value your work

  6. I respect this article for the very much investigated substance and magnificent wording. I got so included in this material that I couldn't quit perusing. I am awed with your work and aptitude. Much obliged to you to such an extent.Mattress Store Denver

  7. This is such an awesome asset, to the point that you are giving and you give it away for nothing.our article has piqued a lot of positive interest. Adjustable Beds Denver

  8. Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that. 借錢

  9. 借錢 借錢

    Excellent read, I just passed this onto a colleague who was doing a little research on that. And he actually bought me lunch because I found it for him smile So let me rephrase that. 借錢

  10. This is certainly as well a really good posting we seriously experienced looking through. It is far from on a daily basis we have risk to check out a little something.

  11. incredible article distributed here by you. i've for a long while been itching to adapt new things with respect to this subject, and i have unquestionably adapted new things today.

  12. Outstanding article! I want people to know just how good this information is in your article. Your views are much like my own concerning this subject. I will visit daily your blog because I know. It may be very beneficial for me.

添加新评论