🔖 文章索引
1. 下載 XAMPP
2. 調整 Document Root
3. 啟動 Apache
4. 連結 MySQL
5. 啟動 MySQL
6. Debug 🐛
7. Install XdebugInstalling Xdebug for XAMPP with PHP 7.x
8. Install VSCode
9. 小地雷
下載 XAMPP
選擇下載 xampp-win32-7.2.8-0-VC15-installer.exe
調整 Document Root
開啟 XAMPP Control Panel
在 Apache
這行點 Config
> Apache (httpd.conf)
在 httpd.conf
文件中搜尋 DocumentRoot
# 將以下路徑調整
DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs">
# 調整為
DocumentRoot "C:/xampp/your_project_name"
<Directory "C:/xampp/your_project_name">
啟動 Apache
開啟 XAMPP Control Panel
在 Apache
這行點 Start
再點 Admin
會開啟網頁
⚠ 如果 Apache port 80 被佔用時需修改 Apache ( httpd.conf )
# 將以下 80 改成 8888
Listen 80
ServerName Localhost:80
連結 MySQL
開啟 XAMPP Control Panel
在 Apache
這行點 Config
> phpMyAdmin (config.inc.php)
# 請參考專案 MySQL 設定
$cfg['Servers'][$i]['host'] = '';
$cfg['Servers'][$i]['user'] = '';
$cfg['Servers'][$i]['password'] = '';
# 將以下註解
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = '';
# 註解後的樣子
/* $cfg['Servers'][$i]['controluser'] = 'pma'; */
/* $cfg['Servers'][$i]['controlpass'] = ''; */
啟動 MySQL
開啟 XAMPP Control Panel
在 MySQL
這行點 Start
再點 Admin
會開啟網頁
Debug 🐛
開啟 XAMPP Control Panel
在 Apache
這行點 Logs
- Apache ( access.log )
- Apache ( error.log )
- PHP ( php_error_log )
Install XdebugInstalling Xdebug for XAMPP with PHP 7.x
https://gist.github.com/odan/1abe76d373a9cbb15bed
Setup
If the file C:\xampp\php\ext\php_xdebug.dll
already exists, you can skip the download.
- Download Xdebug for the specific PHP version:
PHP 7.2 (32-Bit): https://xdebug.org/files/php_xdebug-2.9.7-7.2-vc15.dll
2. Move the downloaded dll file to: C:\xampp\php\ext
3. Open the file C:\xampp\php\php.ini
with Notepad++
4. Disable output buffering: output_buffering = Off
5. Scroll down to the [XDebug]
section (or create it) and copy/paste these lines:
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.7-7.2-vc15.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
;xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "127.0.0.1"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
;36000 = 10h
xdebug.remote_cookie_expire_time = 36000
6. Restart Apache
7. use phpinfo();
check Xdebug Enable
Install VSCode
https://code.visualstudio.com/
VSCode Extension — PHP Debug
- Enable remote debugging in your
php.ini
:
For Xdebug v2.x.x:
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_port = 9000
2. If you are doing web development, don’t forget to restart your webserver to reload the settings.
3. Verify your installation by checking your phpinfo() output for an Xdebug section.
Project root creates .vscode/launch.json
{
// 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": 9000
},
{
"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": 9000,
"serverReadyAction": {
"pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
"uriFormat": "http://localhost:%s",
"action": "openExternally"
}
}
]
}
小地雷 💥
購物車不能刪除品項和不能進行結帳
在用公司專案時有發現根目錄沒有資料夾 LogFiles