다른 버전의 PHP를 사용하여 vscode 우분투 20.04에서 laravel과 함께 xdebug 설치

15640 단어 ubuntuxdebuglaravel

다른 PHP 버전에는 다른 xdebug가 있습니다.



컴퓨터에 설정된 PHP 버전에 따라 xdebug 설치 단계를 따르십시오.

php7.4 -v
php -v




이것은 PHP 버전을 반환할 것입니다. xdebug가 구성되어 있으면 설치하지 않으면 표시됩니다.

xdebug를 설치하자

sudo apt install php7.4-xdebug
sudo apt install php-xdebug



php7.4 --ini
php --ini




찾다
/etc/php/7.4/mods-available/xdebug.ini/etc/php/8.0/mods-available/xdebug.ini
이것을 /etc/php/7.4/mods-available/xdebug.ini에 추가하십시오.

; zend_extension=xdebug.so
zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003


이것을 /etc/php/8.0/mods-available/xdebug.ini에 추가하십시오.
php8.0의 경우

; zend_extension=xdebug.so
zend_extension=/usr/lib/php/20200930/xdebug.so
xdebug.mode = debug
xdebug.start_with_request = yes
xdebug.client_port = 9003


이제 입력

php7.4 -v
php -v


출력에 반환된 xdebug 문자열이 표시되어야 합니다.

어떤 xdebug에 어떤 PHP 버전이 필요한지 혼란스럽다면 참고하세요.



사용 가능한 xdebug.so 파일을 확인하려면 찾기를 사용하고, 위치를 사용할 수 없는 경우 이 cmd를 사용하여 설치하십시오.


sudo apt install mlocatelocate xdebug.so받은 세부 정보를 붙여넣기만 하면 됩니다.

php7.4 -i
php -i


여기 https://xdebug.org/wizard

이제 vscode로 이동


PHP Debug extension펠릭스 베커

이제 vscode에서 laravel 프로젝트를 엽니다.
ctrl+shift+D
디버그 구성 열기
launch.json 생성
여기서 공유한 launch.json과 유사한 파일을 저장합니다.

저를 클릭하십시오 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": 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:8000",
                "-t",
                "public"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9003,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        },
        {
            "name": "php7.4Launch Built-in web server",
            "type": "php",
            "request": "launch",
            "runtimeExecutable": "php7.4",
            "runtimeArgs": [
                // "-dxdebug.mode=debug",
                // "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:8000",
                "-t",
                "public"
            ],
            "program": "",
            "cwd": "${workspaceRoot}",
            "port": 9003,
            "serverReadyAction": {
                "pattern": "Development Server \\(http://localhost:([0-9]+)\\) started",
                "uriFormat": "http://localhost:%s",
                "action": "openExternally"
            }
        }
    ]
}





"runtimeExecutable": "php7.4", //should use php7.4 version
            "runtimeArgs": [
                // "-dxdebug.mode=debug",
                // "-dxdebug.start_with_request=yes",
                "-S",
                "localhost:8000", //similar to php7.4 artisan server
                "-t",
                "public" //should server this folder
            ],


vscode에서 xdebug로 디버깅 시작



녹색 재생 버튼을 클릭하면 다음과 같이 표시됩니다.

좋은 웹페이지 즐겨찾기