Laravel 에서 xdebug 를 통해 디버깅하는 과정을 알아본다.


0. PHP 설치

brew install php71

1. Xdebug 설치 


brew install homebrew/php/<php-version>-xdebug 에서 <php-versino>을 자기에 맞는 php 버전으로 치환 아래는 예제

brew install homebrew/php/php71-xdebug


2. Xdebug 설정 변경하기


맥에서의 위치: /usr/local/etc/php/7.1/conf.d


[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
xdebug.remote_autostart=1
xdebug.default_enable=1
xdebug.remote_port=9001
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1
xdebug.remote_enable=1
xdebug.idekey=PHPSTORM


3. phpstorm run configuraiton 추가


- run configuration 에 들어간후 아래와 같이 PhpWeb Application 을 추가한다



- severs 옆버튼인 ...을 클릭해서 서버를 추가해준다


- + 버튼을 클릭하여 서버를 추가해주고

Host부분을 디버깅하고자 하는 주소를 입력한다

* 주의사항

Use path mappings 를 체크해제한다



Ok를 눌러 돌아온다


4. Phpstorm 의 설정부분에서 Php항목의 Debug 항목을 선택 DBGp Proxy 부분을 아래 스크린샷과 같이 변경. 

IDE key와 Port는 위 Xdebug설정에 맞춰서 입력해주면 된다. 자기 입맛에 맞게 커스터마이즈 하면된다


5. 실제 디버깅하고 싶은 곳에 브레이크 포인트를 설정하고 Debug 버튼을 클릭하면 아래 화면과 같이 해당하는 곳에서 디버거가 멈춰져 있는 것을 확인 가능하다. 



참조: 

1. https://laravel-news.com/xdebug-phpstorm-valet

'PHP > Laravel' 카테고리의 다른 글

Laravel 구동을 위한 Vagrant 설치 및 설정  (0) 2016.09.13

+ Recent posts