2020年8月

1.安装Visual Studio 2019
https://visualstudio.microsoft.com/zh-hans/thank-you-downloading-visual-studio/?sku=Community&rel=16

2.安装时,勾选上“使用 C++ 的桌面开发”
请输入图片描述

3.安装好之后,在开始菜单打开Visual Studio 2019-x64 Native Tools Command Prompt for VS 2019
QQ截图20200827112523.png

4.下载PHP SDK
打开https://github.com/microsoft/php-sdk-binary-tools/releases,下载php-sdk-2.2.0

5.解压PHP SDK
创建php-sdk目录,然后将下载的php-sdk-2.2.0压缩包里php-sdk-binary-tools-php-sdk-2.2.0目录下的所有文件解压到php-sdk目录。

6.切换到刚刚创建的php-sdk目录

cd E:\php-sdk

7.执行“调用初学者脚本”

phpsdk-vs16-x64.bat

输出:

[vcvarsall.bat] Environment initialized for: 'x64'

PHP SDK 2.2.0

OS architecture:    64-bit
Build architecture: 64-bit
Visual C++:         14.27.29111.0
PHP-SDK path:       E:\php-sdk

8.运行批处理脚本
脚本会自动创建所需的目录结构

phpsdk_buildtree phpdev

9.下载php8源代码
打开https://github.com/php/php-src/releases,下载PHP8的源代码压缩包

10.解压PHP源代码
将源代码压缩包内php-src-php-8.0.0beta2目录下的所有文件解压到E:\php-sdk\phpdev\vs16\x64\php-8.0.0-src

11.获取PHP所依赖的库
切换到php源代码目录

cd E:\php-sdk\phpdev\vs16\x64\php-8.0.0-src

使用 PHP SDK 工具通过phpsdk_deps -u命令自动获取适当的依赖关系。这里的下载速度很感人。。。

phpsdk_deps -u

输出

Configuration: 8.0-vs16-x64-stable

Processing package apache-2.4.43-vs16-x64.zip
Processing package c-client-2007f-vs16-x64.zip
Processing package fbclient-3.0.6-nocrt-x64.zip
Processing package freetype-2.9.1-1-vs16-x64.zip
Processing package glib-2.53.3-vs16-x64.zip
Processing package ICU-67.1-vs16-x64.zip
Processing package libargon2-20190702-vs16-x64.zip
Processing package libbzip2-1.0.8-vs16-x64.zip
Processing package libcurl-7.71.1-vs16-x64.zip
Processing package libenchant2-2.2.8-vs16-x64.zip
Processing package libffi-3.3-1-vs16-x64.zip
Processing package libiconv-1.16-2-vs16-x64.zip
Processing package libintl-0.18.3-5-vs16-x64.zip
Processing package libjpeg-9c-vs16-x64.zip
Processing package liblmdb-0.9.22-3-vs16-x64.zip
Processing package liblzma-5.2.5-vs16-x64.zip
Processing package libonig-6.9.5-1-vs16-x64.zip
Processing package libpng-1.6.34-4-vs16-x64.zip
Processing package libpq-11.4-vs16-x64.zip
Processing package libqdbm-1.8.78-vs16-x64.zip
Processing package libsasl-2.1.27-2-vs16-x64.zip
Processing package libsodium-1.0.18-vs16-x64.zip
Processing package libssh2-1.9.0-vs16-x64.zip
Processing package libtidy-5.6.0-2-vs16-x64.zip
Processing package libwebp-1.1.0-vs16-x64.zip
Processing package libxml2-2.9.10-vs16-x64.zip
Processing package libxpm-3.5.12-5-vs16-x64.zip
Processing package libxslt-1.1.34-vs16-x64.zip
Processing package libzip-1.7.1-vs16-x64.zip
Processing package mpir-3.0.0-vs16-x64.zip
Processing package net-snmp-5.7.3-1-vs16-x64.zip
Processing package nghttp2-1.40.0-vs16-x64.zip
Processing package openldap-2.4.47-vs16-x64.zip
Processing package openssl-1.1.1g-vs16-x64.zip
Processing package sqlite3-3.33.0-vs16-x64.zip
Processing package wineditline-2.205-1-vs16-x64.zip
Processing package zlib-1.2.11-vs16-x64.zip
Updates performed successfully.
Old dependencies backed up into 'E:\php-sdk\phpdev\vs16\x64\deps.202008270422'.
buildconf
Rebuilding configure.js
Now run 'configure --help'
configure --help
PHP Version: 8.0.0beta2

Options that enable extensions and SAPI will accept 'yes' or 'no' as a
parameter. They also accept 'shared' as a synonym for 'yes' and request a
shared build of that module. Not all modules can be built as shared modules;
configure will display [shared] after the module name if can be built that
way.

  --enable-snapshot-build           Build a snapshot; turns on everything it
                                    can and ignores build errors
  --with-verbosity                  Output verbosity, 0-2.
  --with-toolset                    Toolset to use for the compilation, give:
                                    vs, clang, icc. The only recommended and
                                    supported toolset for production use is
                                    Visual Studio. Use others at your own
                                    risk.
  --with-cygwin                     Path to cygwin utilities on your system
  --enable-object-out-dir           Alternate location for binary objects
                                    during build
  --enable-debug                    Compile with debugging symbols
  --enable-debug-pack               Release binaries with external debug
                                    symbols (--enable-debug must not be
                                    specified)
  --enable-pgi                      Generate PGO instrumented binaries
  --with-pgo                        Compile optimized binaries using training
                                    data from folder
  --disable-zts                     Thread safety
  --with-prefix                     where PHP will be installed
  --with-mp                         Tell Visual Studio use up to
                                    [n,auto,disable] processes for compilation
  --with-php-build                  Path to where you extracted the
                                    development libraries
                                    (http://wiki.php.net/internals/windows/libs).
                                    Assumes that it is a sibling of this
                                    source dir (..\deps) if not specified
  --with-extra-includes             Extra include path to use when building
                                    everything
  --with-extra-libs                 Extra library path to use when linking
                                    everything
  --with-analyzer                   Enable static analyzer. Pass vs for Visual
                                    Studio, clang for clang, cppcheck for
                                    Cppcheck, pvs for PVS-Studio
  --disable-ipv6                    Disable IPv6 support (default is turn it
                                    on if available)
  --enable-fd-setsize               Set maximum number of sockets for
                                    select(2)
  --with-snapshot-template          Path to snapshot builder template dir
  --disable-security-flags          Disable the compiler security flags
  --without-uncritical-warn-choke   Disable some uncritical warnings
  --enable-sanitizer                Enable ASan and UBSan extensions
  --with-codegen-arch               Architecture for code generation: ia32.
                                    Use --enable-native-intrinsics to enable
                                    SIMD optimizations.
  --with-all-shared                 Force all the non obligatory extensions to
                                    be shared
  --with-config-profile             Name of the configuration profile to save
                                    this to in php-src/config.name.bat
  --disable-test-ini                Enable automatic php.ini generation. The
                                    test.ini will be put into the build dir
                                    and used to automatically load the shared
                                    extensions.
  --with-test-ini-ext-exclude       Comma separated list of shared extensions
                                    to be excluded from the test.ini
  --enable-native-intrinsics        Comma separated list of intrinsic
                                    optimizations to enable. Available
                                    instruction set names are sse, sse2, sse3,
                                    ssse3, sse4.1, sse4.2, avx, avx2. SSE and
                                    SSE2 are enabled by default. The best
                                    instruction set specified will
                                    automatically enable all the older
                                    instruction sets. Note, that the produced
                                    binary might not work properly, if the
                                    chosen instruction sets are not available
                                    on the target processor.
  --enable-apache2handler           Build Apache 2.x handler
  --enable-apache2-2handler         Build Apache 2.2.x handler
  --enable-apache2-4handler         Build Apache 2.4.x handler
  --disable-cgi                     Build CGI version of PHP
  --disable-cli                     Build CLI version of PHP
  --enable-cli-win32                Build console-less CLI version of PHP
  --enable-embed                    Embedded SAPI library
  --enable-phpdbg                   Build phpdbg
  --enable-phpdbgs                  Build phpdbg shared
  --disable-phpdbg-webhelper        Build phpdbg webhelper
  --disable-bcmath                  bc style precision math functions
  --with-bz2                        BZip2
  --disable-calendar                calendar conversion support
  --disable-com-dotnet              COM and .Net support
  --disable-ctype                   ctype
  --with-curl                       cURL support
  --with-dba                        DBA support
  --with-qdbm                       DBA: QDBM support
  --with-db                         DBA: Berkeley DB support
  --with-lmdb                       DBA: Lightning memory-mapped database
                                    support
  --with-enchant                    Enchant Support
  --with-ffi                        ffi support
  --enable-fileinfo                 fileinfo support
  --disable-filter                  Filter Support
  --enable-ftp                      ftp support
  --without-gd                      Bundled GD support
  --without-libwebp                 webp support
  --with-gettext                    gettext support
  --with-gmp                        Include GNU MP support.
  --with-mhash                      mhash support (BC via hash)
  --without-iconv                   iconv support
  --with-imap                       IMAP Support
  --enable-intl                     Enable internationalization support
  --with-ldap                       LDAP support
  --enable-mbstring                 multibyte string functions
  --enable-mbregex                  multibyte regex support
  --without-mysqlnd                 Mysql Native Client Driver
  --with-oci8                       OCI8 support
  --with-oci8-11g                   OCI8 support using Oracle 11g Instant
                                    Client
  --with-oci8-12c                   OCI8 support using Oracle Database 12c
                                    Instant Client
  --enable-odbc                     ODBC support
  --with-odbcver                    Force support for the passed ODBC version.
                                    A hex number is expected, default 0x0350.
                                    Use the special value of 0 to prevent an
                                    explicit ODBCVER to be defined.
  --disable-opcache                 whether to enable Zend OPcache support
  --disable-opcache-jit             whether to enable JIT
  --with-openssl                    OpenSSL support
  --without-pcre-jit                Enable PCRE JIT support
  --with-pgsql                      PostgreSQL support
  --with-pspell                     pspell/aspell (whatever it's called this
                                    month) support
  --without-readline                Readline support
  --disable-session                 session support
  --enable-shmop                    shmop support
  --with-snmp                       SNMP support
  --enable-sockets                  SOCKETS support
  --with-sodium                     for libsodium support
  --with-sqlite3                    SQLite 3 support
  --with-password-argon2            Argon2 support
  --with-config-file-scan-dir       Dir to check for additional php ini files
  --enable-sysvshm                  SysV Shared Memory support
  --with-tidy                       TIDY support
  --disable-tokenizer               tokenizer support
  --enable-zend-test                enable zend-test extension
  --disable-zip                     ZIP support
  --disable-zlib                    ZLIB support
  --without-libxml                  LibXML support
  --without-dom                     DOM support
  --enable-exif                     Exchangeable image information (EXIF)
                                    Support
  --with-mysqli                     MySQLi support
  --enable-pdo                      Enable PHP Data Objects support
  --with-pdo-dblib                  freetds dblib (Sybase, MS-SQL) support for
                                    PDO
  --with-pdo-mssql                  Native MS-SQL support for PDO
  --with-pdo-firebird               Firebird support for PDO
  --with-pdo-mysql                  MySQL support for PDO
  --with-pdo-oci                    Oracle OCI support for PDO
  --with-pdo-odbc                   ODBC support for PDO
  --with-pdo-pgsql                  PostgreSQL support for PDO
  --with-pdo-sqlite                 for pdo_sqlite support
  --disable-phar                    disable phar support
  --enable-phar-native-ssl          enable phar with native OpenSSL support
  --without-simplexml               Simple XML support
  --enable-soap                     SOAP support
  --without-xml                     XML support
  --disable-xmlreader               XMLReader support
  --disable-xmlwriter               XMLWriter support
  --with-xsl                        xsl support

Some influential environment variables:
  CFLAGS      C compiler flags
  LDFLAGS     linker flags
configure --disable-all --enable-cli --enable-$remains
PHP Version: 8.0.0beta2

Saving configure options to config.nice.bat
Checking for cl.exe ...  <in default path>
  Detected compiler Visual C++ 2019
  Detected 64-bit compiler
Checking for link.exe ...  <in default path>
Checking for nmake.exe ...  <in default path>
Checking for lib.exe ...  <in default path>
Checking for bison.exe ...  <in default path>
  Detected bison version 3.3.2
Checking for sed.exe ...  <in default path>
Checking for re2c.exe ...  <in default path>
  Detected re2c version 1.1.1
Checking for zip.exe ...  <in default path>
Checking for lemon.exe ...  <in default path>
Checking for 7za.exe ...  <in default path>
Checking for mc.exe ...  E:\Windows Kits\10\bin\10.0.18362.0\x64
Checking for mt.exe ...  E:\Windows Kits\10\bin\10.0.18362.0\x64
Enabling multi process build

Build dir: E:\php-sdk\phpdev\vs16\x64\php-8.0.0-src\x64\Release_TS
PHP Core:  php8ts.dll and php8ts.lib

Checking for wspiapi.h ...  <in default path>
Enabling IPv6 support
Enabling SAPI sapi\cli
Checking for library edit_a.lib;edit.lib ... <in deps path> \lib\edit_a.lib
Checking for editline/readline.h ...  <in deps path> \include
Enabling extension ext\date
Enabling extension ext\hash
Checking for KeccakHash.h ...  ext/hash/sha3/generic64lc
Enabling extension ext\json
Enabling extension ext\pcre
Enabling extension ext\reflection
Enabling extension ext\spl
Checking for timelib_config.h ...  ext/date/lib
Enabling extension ext\standard

Creating build dirs...
Generating files...
Generating Makefile
Generating main/internal_functions.c
Generating main/config.w32.h
Generating phpize
Done.



Enabled extensions:
-----------------------
| Extension  | Mode   |
-----------------------
| date       | static |
| hash       | static |
| json       | static |
| pcre       | static |
| reflection | static |
| spl        | static |
| standard   | static |
-----------------------


Enabled SAPI:
-------------
| Sapi Name |
-------------
| cli       |
-------------


---------------------------------------
|                   |                 |
---------------------------------------
| Build type        | Release         |
| Thread Safety     | Yes             |
| Compiler          | Visual C++ 2019 |
| Architecture      | x64             |
| Optimization      | PGO disabled    |
| Native intrinsics | SSE2            |
| Static analyzer   | disabled        |
---------------------------------------


WARNING
The following arguments is invalid, and therefore ignored:
 --enable-$remains


Type 'nmake' to build PHP
nmake