http://wed.xjx100.cn/news/139397.html?action=onClick
https://www.bilibili.com/read/cv23429835/
https://www.php.cn/faq/498307.html
安裝iis
選擇卸載程序
安裝php
官網(wǎng)https://www.php.net/下載
選擇線程安全
國內(nèi)地址
其他版本的php下載
下載完成后解壓放到想存放的路徑
添加path環(huán)境變量
命令行中輸入php -v
安裝xdebug
Xdebug 要下載與 php 對應(yīng)的版本,我們下載的 php 版本為 8.2.8,而且是 thread safe 版本,對應(yīng)的是帶 TS 的版本。
xdebug官網(wǎng)
github
下載頁面
把下載的 php_xdebug-3.2.2-8.2-vs16-x86_64.dll 文件,復(fù)制到 php 根目錄下的 ext 目錄中,然后在 php 根目錄下找到 php.ini 文件,有如下兩種情況。
有 php.ini 文件
直接在 php 目錄的 php.ini 的文件末尾添加如下配置即可(記得修改路徑)。
沒有php.ini文件
這里我們可以在 php 根目錄下找到 php.ini-development (開發(fā)環(huán)境用)與 php.ini-production(生產(chǎn)環(huán)境用)兩個文件。這里雖然沒有 php.ini 文件,而 php 還是會去加載 php.ini 作為配置文件的。我們只要選擇其中一個,把它備份,然后重命名為php.ini,最后加入自己個性化的配置即可。這里建議將 php.ini-development 文件備份重命名為 php.ini 就行,如下圖所示:
開啟擴展
;指定xdebug擴展位置
zend_extension=php_xdebug-3.2.2-8.2-vs16-x86_64.dll
;配置xdebug
[xdebug]
;配置xdebug主機地址
xdebug.client_host = localhost
;監(jiān)聽端口
xdebug.client_port = 9103
;idekey
xdebug.idekey = VSCODE
;調(diào)試模式建議設(shè)置成debug可以打斷點調(diào)試,默認是default
xdebug.mode = debug,trace
以上就是最少的xdebug配置了,想知道更多xdebug配置介紹可以去官網(wǎng)看看 Xdebug: Documentation ? All settings ,里面都有介紹什么配置有什么功能。
最后可以在命令行輸入php -m
查看是否安裝xdebug成功
iis開啟php支持
新建網(wǎng)站
Windows默認自帶的Web服務(wù)器是IIS(Internet Information Services),支持ASP和.Net(aspx),如果要支持對PHP文件的解析,可以通過以下兩種方式:
(1)通過FastCGI,將擴展名為.php的文件指定到PHP官方的fast CGI引擎中去解析。
(2)使用反向代理,將指定網(wǎng)站反向代理到Apache服務(wù)商,或者php-fpm服務(wù)進程中。
我們這里通過第一種方式,即FastCGI,在IIS的全局,或者指定網(wǎng)站,選擇“處理程序映射”這個功能模塊。
設(shè)置默認頁面
處理500錯誤
新建index.php內(nèi)容如下
<?php
phpinfo();
開啟php.ini下
short_open_tag = On
重新啟動iis應(yīng)用程序池
訪問
vscode
安裝vscode,安裝phpdebug插件
修改php.ini
;配置xdebug
[xdebug]
;配置xdebug主機地址
xdebug.client_host = localhost
;監(jiān)聽端口
xdebug.client_port = 9103
;idekey
xdebug.idekey = VSCODE
;調(diào)試模式建議設(shè)置成debug可以打斷點調(diào)試,默認是default
xdebug.mode = debug,trace
xdebug.start_with_request = yes
重啟應(yīng)用程序池
vscode增加配置
"php.validate.executablePath": "E:\\PHP\\php-8.2.8-Win32-vs16-x64\\php.exe",
"php.debug.executablePath": "E:\\PHP\\php-8.2.8-Win32-vs16-x64\\php.exe",
"phpserver.phpConfigPath": "E:\\PHP\\php-8.2.8-Win32-vs16-x64\\php.ini",
"phpserver.phpPath": "E:\\PHP\\php-8.2.8-Win32-vs16-x64\\php.exe",
創(chuàng)建json配置文件
內(nèi)容如下:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9003,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
因為xdebug配置的是監(jiān)聽9103所以需要修改配置文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9103
},
{
"name": "Launch currently open script",
"type": "php",
"request": "launch",
"program": "${file}",
"cwd": "${fileDirname}",
"port": 0,
"runtimeArgs": [
"-dxdebug.start_with_request=yes"
],
"env": {
"XDEBUG_MODE": "debug,develop",
"XDEBUG_CONFIG": "client_port=${port}"
}
},
{
"name": "Launch Built-in web server",
"type": "php",
"request": "launch",
"runtimeArgs": [
"-dxdebug.mode=debug",
"-dxdebug.start_with_request=yes",
"-S",
"localhost:0"
],
"program": "",
"cwd": "${workspaceRoot}",
"port": 9103,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
這里配置了三種方式文章來源:http://www.zghlxwxcb.cn/news/detail-607993.html
- Listen for xdebug是監(jiān)聽服務(wù)器請求的時候觸發(fā)
- 直接訪問當(dāng)前的頁面
- 啟動一個web服務(wù),然后監(jiān)聽斷點
再推薦一款插件:PHP Intelephense文章來源地址http://www.zghlxwxcb.cn/news/detail-607993.html
到了這里,關(guān)于windows下搭建php開發(fā)環(huán)境的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!