search
HomeBackend DevelopmentPHP TutorialDetailed graphic explanation of how to debug visual studio code in PHP

本篇文章主要介绍了visual studio code 调试php方法(图文详解),具有一定的参考价值,有兴趣的可以了解一下

简介

php是动态语言没有调试器的话排错起来很是麻烦。vscode可以说是程序员的福音,启动速度快,插件越来越多,跨平台。现在说一下vscode上调试php文件

所需文件

  • xampp 集成服务器

  • vscode

  • Xdebug

  • php-debug 插件

1: 在vscode中按 F1, 输入ext install php-debug 安装调试插件

2:去 https://xdebug.org/download.php下载php对应版本的插件,php版本可以在xampp中的readme看到,下载这个PHP 5.6 VC11 TS (32 bit) 把dll文件拷贝到php目录

Detailed graphic explanation of how to debug visual studio code in PHP

3:打开php目录下的php.ini ,添加几行配置,xdebug的路径按实际情况配置,配置完成后重启apache服务器


zend_extension=C:\xampp\php\ext\php_xdebug-2.4.1-5.6-vc11.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

4:第一次安装vs会提示这个,需要配置下php.exe的路径,在用户设置里添加以下项


"php.validate.executablePath": "C:\\xampp\\php\\php.exe"

Detailed graphic explanation of how to debug visual studio code in PHP

5:在vscode中的php文件打一断点,点Listen for XDebug 项目的运行,配置不用更改,默认就可以
Detailed graphic explanation of how to debug visual studio code in PHP

6:运行后跳出这些按键

Detailed graphic explanation of how to debug visual studio code in PHP

7:直接在浏览器中打开要调试的php(不是文件路径而是服务器的地址(http://127.0.0.1/test.php)),vscode就会命中到打断点的地方

Detailed graphic explanation of how to debug visual studio code in PHP

注意事项

php最大执行时间好像是30秒,超过30秒会自动终止,因此调试的时候要修改一下时间,在php.ini 文件中修改最大运行时间为5分钟


max_execution_time=3000

拓展

hbuilder和vscode 配置xdebug时候是一样的,在浏览器打开文件hbuilder会自动命中断点

Detailed graphic explanation of how to debug visual studio code in PHP

The above is the detailed content of Detailed graphic explanation of how to debug visual studio code in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the difference between unset() and session_destroy()?What is the difference between unset() and session_destroy()?May 04, 2025 am 12:19 AM

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

What is sticky sessions (session affinity) in the context of load balancing?What is sticky sessions (session affinity) in the context of load balancing?May 04, 2025 am 12:16 AM

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

What are the different session save handlers available in PHP?What are the different session save handlers available in PHP?May 04, 2025 am 12:14 AM

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

What is a session in PHP, and why are they used?What is a session in PHP, and why are they used?May 04, 2025 am 12:12 AM

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

Explain the lifecycle of a PHP session.Explain the lifecycle of a PHP session.May 04, 2025 am 12:04 AM

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

What is the difference between absolute and idle session timeouts?What is the difference between absolute and idle session timeouts?May 03, 2025 am 12:21 AM

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

What steps would you take if sessions aren't working on your server?What steps would you take if sessions aren't working on your server?May 03, 2025 am 12:19 AM

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

What is the significance of the session_start() function?What is the significance of the session_start() function?May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.