This article will introduce to you how to use VS2015 (vs14) to develop PHP7 extensions. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

Preparation work before development:
VS (I use 2013)
Cygwin (Download address: http://www. cygwin.com/)
Equipped with IIS7.5 of PHP running environment (used for testing)
php compiled program and pre-compiled source code, I am using the latest version 7.0. 5 (Download address: http://windows.php.net/download#php-7.0)
Compiled program path: E:\vs_c \test\phpext\php-7.0.5-src
Source code path before compilation: E:\vs_c \test\phpext\php-7.0.5-nts-Win32-VC14-x86\
Steps:
1. Install Cygwin

Install from the network













TEST=1 (The red part here needs to be changed to your extension name. If you don’t change it to your extension name, php will not recognize it)
TEST (Here The red part needs to be changed to your extension name. If you don’t change it to your extension name, PHP will not recognize it)
ZTS (Adding this variable turns on thread safety, not adding it turns off thread safety. You can judge whether to add this variable based on whether the php you compiled is thread safe. ps: I suffered a loss because of not responding. PHP does not recognize the extension)

Generate the solution. The error message shows that "config.w32.h" cannot be found. Search for "config.w32.h" in the source code file directory. h", find "config.w32.h.in" in the E:\vs_c \test\phpext\php-7.0.5-src\win32\build\ folder, and copy this file to E:\vs_c \test \phpext\php-7.0.5-src\main\ folder, remove the following ".in"
Generate the solution again, and the error message LNK1120
error 7 error LNK1120: 5 unresolved external commands E:\vs_c \test\phpext\php-7.0.5-src\ext\test\Release\phptest.dll 1 1 phptest
right-click project properties, connector, enter , additional dependencies, edit, put the path to php5.lib (this file is in the program folder after php is compiled, in the dev folder of the root directory)
Note: In order to allow the extension to work with php The running environment matching depends on the compiled version of your php running environment (php7.0.5 is compiled by VC14), which is the config in the E:\vs_c\test\phpext\php-7.0.5-src\main\ folder. Add to the w32.h file:
#define PHP_COMPILER_ID "VC14"
Open E:\vs_c \test\phpext\php-7.0.5-src\ext\test\test.c
Find this paragraph Code:
PHP_FUNCTION(confirm_test_compiled)
{
char *arg = NULL;
int arg_len, len;
char *strg;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
return;
}
len = spprintf(&strg, 0, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "test", arg);
RETURN_STRINGL(strg, len, 0);
}Change confirm_test_compiled to test_echo
Find this code again:
const zend_function_entry test_functions[] = {
PHP_FE(confirm_test_compiled, NULL) /* For testing, remove later. */
PHP_FE_END /* Must be the last line in test_functions[] */
};Change confirm_test_compiled inside to test_echo
To generate a solution, find your own php extension phptest.dll in the Release folder of the project root directory, copy it to the ext folder of php, and configure it in php.ini:
extension=phptest.dll
Restart IIS, create a new site, and create a new test.php file in it
<?php
echo test_echo("123");Run and get the result:

The above is the detailed content of How to develop PHP7 extensions with VS2015 (vs14). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),






