Web/PHP

[VS Code PHP 오류] Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.

Hannah_ko 2021. 7. 15. 18:30
SMALL
Cannot validate since no PHP executable is set. Use the setting 'php.validate.executablePath' to configure the PHP executable.

 

위와 같은 오류 발생시 해결방법

 

1. PHP가 설치되어 있는지 확인

1-1. 없을 경우 PHP 설치

  1) windows의 경우 직접 파일 다운로드 후 압축 해제 (저장 경로 기억해두기)

https://www.php.net/downloads.php

  저장 경로 예시: C:/PHP/php.exe

 

  2) mac OS의 경우 설치되어 있음

# linux, macOS php 위치 찾는 방법

>>> whereis php
/usr/bin/php

  저장 경로 예시:  /usr/bin/php   or   usr/local/bin/php

 

 

2. VS Code php setting 변경하기

   1) settings 켜기

      1-1) Windows: File -> Preferences -> Settings

      1-2) Mac: Code -> Preferences -> Settings

 

   2) extensions 탭 선택 -> PHP -> Edit in settings.json 선택

 

  3) settings.json 파일 수정하기

{
	...
    "php.validate.executablePath": "/usr/bin/php"
}

  settings.json 파일에   "php.validate.executablePath": "PHP 위치" 추가 입력 후 저장

 

  4) VS code 재실행 후 php 파일 확인

      오류가 생기지 않으면 세팅 성공

LIST