Windows Php Apache Phpstorm VS Code

  1. 安装 Visual C++ Redistributable for Visual Studio 2015

  2. 安装php

  3. 安装配置xdebug

        [Xdebug]
        zend_extension="示例:E:phpextphp_xdebug.dll"
        xdebug.remote_enable=1
        xdebug.remote_host=localhost
        xdebug.remote_port=9000
        xdebug.idekey = PHPSTORM
    
  4. Phpstorm配置

    • File | Settings | Languages & Frameworks | PHP
      • 选中php.exe 或 php-cgi.exe
  5. Phpstorm运行

  6. Phpstorm Debug

    • 打断点

    • 点击这个按钮, 使他变成监听状态, 不Debug时关闭它

    • 然后再次运行

    • 如果弹出窗口的默认就ok

  7. 安装Apache (使用phpstorm则不必安装)

        Define SRVROOT "示例:E:/Apache24"
        LoadModule php7_module "示例:E:/php/php7apache2_4.dll"
        PHPIniDir "示例:E:/php"
        AddHandler application/x-httpd-php .php
        AddType application/x-httpd-php .php
        ServerName 127.0.0.1:80
        DirectoryIndex index.php index.html
        DocumentRoot "示例:E:/html"
            
    
    • 打开管理员cmd 在Apache 下的 bin 目录执行
        httpd -k install
        htppd -k start
    
    • 在网页目录下创建index.php
      • index.php
          <?php
          phpinfo();
          ?>
      
    • 在浏览器中打开 127.0.0.1/index.php 查看是否安装成功
  8. VS Code 配置

    • 安装插件
      • PHP Debug
      • PHP Intelephense
      • PHP IntelliSense
    • 修改settings.json文件
      • 添加配置, 输入php.exe地址或者php-cgi.exe地址,示例
          "php.validate.executablePath": "示例:E:\php\php-cgi.exe"
      
    • 直接修改文件, 在浏览器中就可以看到改变, 即改完代码不需要执行, 和写前端一样
    • F5执行 Listen for XDebug, 开始Debug
      • 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": 9000
                  //}
              ]
          }
      
    • 调试前要先在浏览器中打开页面
      参考链接: https://www.jeffgeerling.com/blog/2018/installing-php-7-and-composer-on-windows-10
原文地址:https://www.cnblogs.com/twfb/p/9951118.html