[VSCode] XDebug PHP 디버깅 환경 설정
- 공유 링크 만들기
- 이메일
- 기타 앱
[VSCode] XDebug PHP 디버깅 환경 설정
o 개요
- 서버 os환경/구동환경에 따른 웹서버, php 등 설치 과정은 아래 내용에서 제외함.
- 원격 웹서버 php 페이지를 로컬 개발 환경에서 디버깅
o [서버 > 개발pc] xdebug 설치 마법사 실행 : https://xdebug.org/wizard
서버의 php -i 결과를 위 url에 붙여넣고 'analyse my phpinfo() output' 버튼 클릭
ex) 마법사 페이지
결과화면 예)
o [서버] xebug 모듈 설치
위 진단 결과의 instructions 내용대로 진행
(xdebug 소스 다운로드 > 빌드 > 동적 lib (*.so)파일 모듈 디렉토리에 copy)
** 빌드(컴파일) 위해서는 phpize가 설치되어 있어야 함. (ex. yum install php-devel 등), gcc, makefile등 컴파일 환경도... (c코드임) **
o [서버] php.ini 설정 && 해당 프로세스 재시작
... (마지막쯤) [xDebug] zend_extension = /usr/lib64/php/modules/xdebug.so xdebug.remote_enable=true xdebug.remote_host=개발PC IP (서버에서 내 PC가 접속가능해야 함. 도커의 경우 host.docker.internal) xdebug.remote_port=9001 xdebug.remote_handler=dbgp
웹 서버를
- apache httpd 사용할 경우 httpd 재시작
- nginx 이용의 경우 php-fpm 재시작
o [개발pc] vscode 설정
1) PHP debug 플러그인 설치
2) workspace 생성 or 열기
3) Debug > Open configurations : launch.json 편집 (port확인(php.ini에 설정한), pathMappings 설정)
ex) https://server/info.php 요청
/remote/doc/root/info.php <--- 그 대상 (원격서버)
${workspaceRoot}/info.php <--- 디버깅 대상 php 파일 (내 hdd/ssd)
** 각 파일을 동기화하거나 nfs등으로 공유하던가 알아서(?) 편한대로 하셈 **
{ // 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": 9001, "pathMappings": { "서버 doc root(ex: /remote/doc/root)" : "${workspaceRoot}" } }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000 } ] }
** php-storm 등 xdebug를 지원하는 ide의 경우도 port와 path경로 설정만 주의해서 설정하면 될듯 **
o [개발pc] 크롬브라우저 : Xdebug helper 설치
o [개발pc] Debug > Start Debugging & php파일 열고 break point 걸기
o [개발pc] 크롬브라우저에서 Xdebug helper를 'Debug' 모드로 변경하고 php 페이지 열기 (http://server/info.php)
o [개발pc] vscode에서 BP 확인
o 동작원리
- vscode의 php debug모듈이 9001번 포트 서버 listen 중 (php debug플러그인)
- 원격 웹서버가 info.php파일 요청 수신시 php.ini에 설정된 xebug 정보로(xdebug.remote_host, xdebug.remote_port)
tcp 연결 시도 (vscode의 플러그인으로 접속) > tcp세션 연결되어 디버깅 모드 실행
** 서버 & 개발 pc 모두 netstat등으로 tcp 포트 조회하여 연결 상태 확인 **
ex) 순서
[서버]
nginx -c /etc/nginx/nginx.conf
php-fpm 실행
[pc]
vscode : workspace열기 / php파일 열고 bp
크롬브라우저 : php페이지 열기
[참고]
https://marketplace.visualstudio.com/items?itemName=felixfbecker.php-debug
https://www.jetbrains.com/help/phpstorm/browser-debugging-extensions.html
https://www.nginx.com/resources/wiki/start/topics/tutorials/commandline/
from http://woonizzooni.tistory.com/90 by ccl(A) rewrite - 2020-03-06 05:54:12
- 공유 링크 만들기
- 이메일
- 기타 앱
댓글
답글삭제if you download latest version of this software so
https://wincracker.com/
Jetbrains PHP Storm IDE Crack
Security Monitor Pro Crack
Gather Proxy Premium Crack
Kon-Boot Crack