Home php教程 php手册 windows下配置php5.5开发环境及开发扩展

windows下配置php5.5开发环境及开发扩展

Jun 06, 2016 pm 08:15 PM
windows development environment

这篇文章主要介绍了windows下配置php5.5开发环境及开发扩展,非常的详细,非常全面,是篇非常不错的php基础文章,这里推荐给大家。

网上的教程是比较多的,但是我发现在windows下的扩展开发比较少,而且大多都是php5.3版本以前的,今天我就给大家讲解一下php扩展开发,,我就拿php5.5的版本来说明一下的了

windows环境(我个人的)

复制代码 代码如下:


windows 8.1 企业版(mac os Boot Camp安装的)
Visual Studio 2012 版本
msysgit  ( 下载)
php-sdk-binary-tools-20110915.zip (下载)
deps-5.5-vc11-x86.7z                  (下载)
php-5.5.20                        (下载,这个版本不定自己选择)

第一步
解压php-sdk-binary-tools的二进制包,譬如我解压到我的C:\php-sdk文件夹中,现在的目录结构如下

复制代码 代码如下:


C:\php-sdk
    --bin
    --script
    --share

然后,这个是你已经安装完成了visual studio 2012,打开VS2012 Native Tools Command Prompt命令行工具

复制代码 代码如下:


#进入目录
cd C:\php-sdk
#设置环境变量
bin\phpsdk_setvars.bat
#创建常用的php-sdk目录
bin\phpsdk_buildtree.bat phpdev

如果我们打开bin\phpsdk_buildtree.bat文件就会发现它只创建到VC9,没有VC11,但是我们如果开发php5.5版本,我们需要的是VC11,这时候我们就要把C:\php-sdk\phpdev\vc9复制一份到C:\php-sdk\phpdev\vc11,现在的目录结构如下:

复制代码 代码如下:


C:\php-sdk\phpdev\
                --vc6
                --vc8
                --vc9
                --vc11

因为我下载的deps-5.5-vc11-x86.7z,所以我要解压deps-5.5-vc11-x86.7z到C:\php-sdk\phpdev\vc11\x86\deps文件夹下覆盖,里边都是我们需要的库文件和一些必要的工具等等。
然后,将我们下载的php-5.5.20.tar.bz2解压到C:\php-sdk\phpdev\vc11\x86\php-5.5.20文件夹中。

编译安装php

回到VS2012 Native Tools Command Prompt
#进入php源目录文件夹
cd c:\php-sdk\phpdev\vc11\x86\php-5.5.20
buildconf
#查看带的扩展和编译命令
configure --help
php-sdk

如果你没有安装php,现在这里就帮助到你了,可以先编译安装一下php
configure --disable-all --enable-cli
然后,你会看到Type 'nmake' to build PHP,然后编译
nmake
在C:\php-sdk\phpdev\vc11\x86\php-5.5.20\Release_TS文件夹下就生成了php.exe文件,环境变量中加入这个路径,好在命令行中能使用php命令。

开发PHP的第一个扩展

假如我们要开发一个widuu()函数,实现的效果如下

复制代码 代码如下:


function widuu($string){
    return "your first extension {$string} is ok";
}

进入扩展目录,生成扩展文件夹

复制代码 代码如下:


cd C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext
#输入php ext_skel_win32.php --extname=扩展名称
php ext_skel_win32.php --extname=widuuweb


这时候我们在C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext就看到了自己的目录widuuweb,打开widuuweb\php_widuuweb.h,在
#PHP_MINFO_FUNCTION(widuuweb);下一行写入自己的函数,譬如我定义的是widuu()函数
PHP_FUNCTION(widuu);
打开php_widuuweb.c编写函数,在PHP_FUNCTION(confirm_widuuweb_compiled)下

复制代码 代码如下:


PHP_FUNCTION(widuu){
    char *arg_string = NULL;
    int  arg_len,str_len;
    char *string;
    if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"s",&arg_string,&arg_len) == FAILURE){
        return;
    }
    str_len = spprintf(&string,0,"your first extension %.78s is ok",arg_string);
    RETURN_STRINGL(string,str_len,0);
}

然后找到PHP_FE(confirm_widuuweb_compiled, NULL),在下边注册你的函数

复制代码 代码如下:


const zend_function_entry widuuweb_functions[] = {
    PHP_FE(confirm_widuuweb_compiled,   NULL)       /* For testing, remove later. */
    PHP_FE(widuu,NULL)
    PHP_FE_END  /* Must be the last line in widuuweb_functions[] */
};

修改C:\php-sdk\phpdev\vc11\x86\php-5.5.20\ext\widuuweb\config.w32,去掉
// ARG_ENABLE("widuuweb", "enable widuuweb support", "no");
前边的注释,vs命令行,输入cd .. 到php-5.5.20目录中,输入下面的命令
buildconf --force
#查看扩展
configure --help
如果,有错误,大家可以打开,目录下configure.js查看,我这个出现了错误,是configure.js的4791行,
ARG_ENABLE("widuuweb", "enable widuuweb support", "no");  */
多了一个*/的注释,去掉就可以了,然后再输入
configure --help
就看到了,有一行
 --enable-widuuweb             enable widuuweb support
然后配置
configure --disable-all --enable-cli --enable-widuuweb=shared
php动态扩展

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Can I install mysql on Windows 7 Can I install mysql on Windows 7 Apr 08, 2025 pm 03:21 PM

Yes, MySQL can be installed on Windows 7, and although Microsoft has stopped supporting Windows 7, MySQL is still compatible with it. However, the following points should be noted during the installation process: Download the MySQL installer for Windows. Select the appropriate version of MySQL (community or enterprise). Select the appropriate installation directory and character set during the installation process. Set the root user password and keep it properly. Connect to the database for testing. Note the compatibility and security issues on Windows 7, and it is recommended to upgrade to a supported operating system.

How to speed up the loading speed of PS? How to speed up the loading speed of PS? Apr 06, 2025 pm 06:27 PM

Solving the problem of slow Photoshop startup requires a multi-pronged approach, including: upgrading hardware (memory, solid-state drive, CPU); uninstalling outdated or incompatible plug-ins; cleaning up system garbage and excessive background programs regularly; closing irrelevant programs with caution; avoiding opening a large number of files during startup.

How to pull the vertical reference line of PS How to pull the vertical reference line of PS Apr 06, 2025 pm 08:18 PM

Pull vertical guides in Photoshop: Enable ruler view (View > ruler). Hover the mouse over the vertical edge of the ruler, and then the cursor becomes a vertical line with double arrows and hold and drag the mouse to pull out the reference line. Click Delete by dragging the guide, or hovering it into a cross.

Unable to access mysql from terminal Unable to access mysql from terminal Apr 08, 2025 pm 04:57 PM

Unable to access MySQL from the terminal may be due to: MySQL service not running; connection command error; insufficient permissions; firewall blocks connection; MySQL configuration file error.

How to solve mysql cannot connect to local host How to solve mysql cannot connect to local host Apr 08, 2025 pm 02:24 PM

The MySQL connection may be due to the following reasons: MySQL service is not started, the firewall intercepts the connection, the port number is incorrect, the user name or password is incorrect, the listening address in my.cnf is improperly configured, etc. The troubleshooting steps include: 1. Check whether the MySQL service is running; 2. Adjust the firewall settings to allow MySQL to listen to port 3306; 3. Confirm that the port number is consistent with the actual port number; 4. Check whether the user name and password are correct; 5. Make sure the bind-address settings in my.cnf are correct.

Solutions to the errors reported by MySQL on a specific system version Solutions to the errors reported by MySQL on a specific system version Apr 08, 2025 am 11:54 AM

The solution to MySQL installation error is: 1. Carefully check the system environment to ensure that the MySQL dependency library requirements are met. Different operating systems and version requirements are different; 2. Carefully read the error message and take corresponding measures according to prompts (such as missing library files or insufficient permissions), such as installing dependencies or using sudo commands; 3. If necessary, try to install the source code and carefully check the compilation log, but this requires a certain amount of Linux knowledge and experience. The key to ultimately solving the problem is to carefully check the system environment and error information, and refer to the official documents.

MySQL can't be installed after downloading MySQL can't be installed after downloading Apr 08, 2025 am 11:24 AM

The main reasons for MySQL installation failure are: 1. Permission issues, you need to run as an administrator or use the sudo command; 2. Dependencies are missing, and you need to install relevant development packages; 3. Port conflicts, you need to close the program that occupies port 3306 or modify the configuration file; 4. The installation package is corrupt, you need to download and verify the integrity; 5. The environment variable is incorrectly configured, and the environment variables must be correctly configured according to the operating system. Solve these problems and carefully check each step to successfully install MySQL.

Is PS slow loading related to other programs that are running? Is PS slow loading related to other programs that are running? Apr 06, 2025 pm 06:03 PM

The secrets to mastering Office software include: understanding different versions and platforms, correctly installing and configuring, proficient in using the software interface, in-depth understanding of feature operations, application collaboration and sharing functions, utilizing templates and styles, mastering advanced skills, and solving common problems. In addition, you need to choose a version that suits your needs, make good use of templates and styles, develop backup habits, and learn shortcut keys and advanced techniques to improve efficiency.

See all articles