PHPStorm + XDebug Setup Walkthrough

前端 未结 6 657
渐次进展
渐次进展 2020-11-30 19:58

Up until recently, I\'ve been writing code in PHP (via Notepad++) and debugging by checking the logs in IIS (gotta love that web-platform installer); I\'ve since decided to

6条回答
  •  悲&欢浪女
    2020-11-30 20:46

    1. install xdebug module (MAC installation steps)
    1.1.1. check what PHP version u r using php --ini (see the loaded file)
    1.1.2. brew search xdebug
    1.1.3. brew install phpXX-xdebug
    1.1.4. see details: php -i | grep xdebug
    1.2. restart server
    1.3. configuration
    1.3.1. sudo find /usr -name 'xdebug.so'
    1.3.2. copy the path of the exact one you need
    example: /usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so
    1.3.3. edit the extension related configuration file which should be injected to the main php.ini automatically:
    subl /usr/local/etc/php/5.6/conf.d/ext-xdebug.ini
    1.3.4. add the zend_extension to be = the path copied above

     [xdebug]  
     zend_extension="/usr/local/Cellar/php56-xdebug/2.3.2/xdebug.so"
    

    Normal file should have something like this:

    [xdebug]
    zend_extension="/usr/local/Cellar/php56/5.6.4/lib/php/extensions/no-debug-non-zts-20131226/xdebug.so"
    
    
    xdebug.remote_enable=1
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    xdebug.remote_handler="dbgp"
    xdebug.remote_autostart=1
    xdebug.profiler_enable=1
    xdebug.profiler_output_dir="~/xdebug/phpstorm/tmp"
    xdebug.idekey=PHPSTORM
    

    2. check your PHP version
    php --ini
    3. setup the IDE settings
    preference > languages and framework > PHP >
    3.1. set the language level to the correct PHP version of this project
    3.2. set an interpreter (set the parent directory of where the bin directory of PHP executable is loaded)
    3.2.1. click the … button > click the + button > other local > set PHP Excitable path,
    to find the path type in the terminal: $ which php
    example: /usr/local/Cellar/php56/5.6.5/bin/php
    4. restart phpstorm
    5. now let’s make it work
    5.1. run > edit configuration > click the green + button on the left > select b. php web application
    5.2. name: anything example ur {application name - debugger}
    5.3. server: localhost (browse > + > name: whatever | host: localhost or 127.0.0.1)
    5.4. click ok
    5.5. start url: the link of ur project homepage: http://127.0.0.1:80/SomethingNew/
    5.6. click ok
    6. now set the break point and click debug

提交回复
热议问题