create account

Fully step by step guide how to debug php by vim+vdebug and xdebug by alanzheng

View this thread on: hive.blogpeakd.comecency.com
· @alanzheng · (edited)
$0.02
Fully step by step guide how to debug php by vim+vdebug and xdebug
#### Repository
https://github.com/AlanZheng/Tutorial.devel

#### What Will I Learn?
- How to recompile vim from source code to enable a feature, such as enable python3
- How to configure the vdebug for vim.
- How to configure xdebug and work together with vdebug.

#### Requirements
- CentOS e17
- vim source code: https://github.com/vim/vim
- vdebug source code: https://github.com/vim-vdebug/vdebug
- PHP 5.6.38
- xdebug 2.5.5

#### Difficulty
- Intermediate

#### Tutorial Contents
1. Verifying vim information by run: **vim --version** to see its output  is +python3  or -python3, plus symbol means this feature enable, otherwise disabled. The default vim distribution disabled python3 on CentOS e17. So we have recompiled the vim from source code to enable it.

   ![vim_version](https://github.com/AlanZheng/Tutorial.devel/raw/master/vim_version.png)

2. Get the vim source code from : https://github.com/vim/vim by below command:

   ```
   git clone https://github.com/vim/vim.git
   ```

   Then changing the directory into vim source code to run **./configure --enable-python3interp=yes**, after that just type make command to compile it. if things done you can find the vim executable in src directory, so goes into src directory and run **./vim --version** to check again. I believe the output will have **+python3** as above picture. Now you can install the new vim to replace the default one.

3. Get the vdebug source code from https://github.com/vim-vdebug/vdebug.git by below command:
    ```
    git clone https://github.com/vim-vdebug/vdebug.git`
    ```
    Then copy/move its content in your ~/.vim/ directory. You should call **:helptags ~/.vim/doc** in vim to generate the necessary help tags, after that to run **:help vdebug** in vim, if you see something like below, that means your vdebug worked well with vim.

    ![vdebug_doc](https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_doc.png)

4. Add below code into your ~/.vimrc 
    ```
    let g:vdebug_options = {}
    let g:vdebug_options["port"] = 7000
    ```

5. Configure your xdebug, you should add below code into your php.ini:
    ```
    xdebug.remote_enable=1
    xdebug.remote_host=127.0.0.1
    xdebug.remote_port=7000
    xdebug.remote_log="/tmp/xdebug.log"
    ```
    NOTE: the xdebug's port must same with vdebug's as above.

6. To create a file phpinfo.php, and put below code in it.
    ```
    <?php phpinfo(); ?>
    ```
    Then to verify if xdebug configure worked well:
    ```
    php phpinfo.php | grep xdebug
    ```

7. Open a php file by vim, then press **F10** to set a break point to cursor line, then press **F5** to let vdebug waiting for connection as below.

    ![vdebug_break](https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_break.png)

8. After that to access this php from browser(firefox/chrome), the  xdebug should work now, and you will able to see debug status in the vim, more vdebug command you can type **:help vdebug** in vim.

    ![vdebug_debug](https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_debug.png)

    If there is anything won't work for your case, please contact me freely.

#### Refer to:
http://alanzheng.top/doku.php?id=tutorials:php:debug_php_by_vim
👍  , , , , , , , , , , , , , , , ,
properties (23)
authoralanzheng
permlinkhow-to-debug-php-by-vim-vdebug-and-xdebug
categoryutopian-io
json_metadata{"tags":["utopian-io","tutorials","vim","vdebug","xdebug"],"image":["https://github.com/AlanZheng/Tutorial.devel/raw/master/vim_version.png","https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_doc.png","https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_break.png","https://github.com/AlanZheng/Tutorial.devel/raw/master/vdebug_debug.png"],"links":["https://github.com/AlanZheng/Tutorial.devel","https://github.com/vim/vim","https://github.com/vim-vdebug/vdebug","https://github.com/vim-vdebug/vdebug.git","http://alanzheng.top/doku.php?id=tutorials:php:debug_php_by_vim"],"app":"steemit/0.1","format":"markdown"}
created2018-10-16 13:58:39
last_update2018-10-22 11:23:39
depth0
children3
last_payout2018-10-23 13:58:39
cashout_time1969-12-31 23:59:59
total_payout_value0.022 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length3,229
author_reputation2,727,533,211,976
root_title"Fully step by step guide how to debug php by vim+vdebug and xdebug"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,413,930
net_rshares24,017,891,500
author_curate_reward""
vote details (17)
@yokunjon ·
$7.67
I thank you for your contribution. Here are my thoughts;

* **Structure**

  * Formatting of the post is kinda untidy and images are not showing. I advise you to use markdown language to format.

* **Language**

  * Your post contains a large number of complex sentences. They are understandable, but addressing them will both increase your language ability and the efficiency of the post. Here is an example sentence:
    
    * "To verify if your vim enable python3 by run: vim --version, it will output below information, if you see +python3, that means your vim enabled python3, if you see -python3, that means you need recompile vim from source code to enable python3."

    As you can see, there are multiple sentences in one sentence, separated with commas. Some languages like Turkish support this kind of sentence-crafting and it is quite easy to understand that. But in English, it can result in complex sentences.

* **Content**

  * You might consider changing topics to preserve some uniqueness. The concept is generally too simple and similar can be easily found on the internet. Being unique with tutorials on Utopian is not required, but preferable as we value rare posts more than others. 

----
Your contribution has been evaluated according to [Utopian policies and guidelines](https://join.utopian.io/guidelines), as well as a predefined set of questions pertaining to the category.

---- 
Need help? Write a ticket on https://support.utopian.io/. 
Chat with us on [Discord](https://discord.gg/uTyJkNm). 
[[utopian-moderator]](https://join.utopian.io/)
👍  , , , , , , , , , , , ,
properties (23)
authoryokunjon
permlinkre-alanzheng-how-to-debug-php-by-vim-vdebug-and-xdebug-20181016t161846208z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"links":["https://join.utopian.io/guidelines","https://support.utopian.io/","https://discord.gg/uTyJkNm","https://join.utopian.io/"],"app":"steemit/0.1"}
created2018-10-16 16:18:48
last_update2018-10-16 16:18:48
depth1
children2
last_payout2018-10-23 16:18:48
cashout_time1969-12-31 23:59:59
total_payout_value5.792 HBD
curator_payout_value1.877 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,572
author_reputation19,266,807,595,513
root_title"Fully step by step guide how to debug php by vim+vdebug and xdebug"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,422,947
net_rshares6,105,604,650,173
author_curate_reward""
vote details (13)
@alanzheng ·
@yokunjon, thanks for review and suggestion! I fixed them, please review it again. I write the markdown by Typora, if you know better one, please suggest. :-)
👍  
properties (23)
authoralanzheng
permlinkre-yokunjon-re-alanzheng-how-to-debug-php-by-vim-vdebug-and-xdebug-20181017t052226190z
categoryutopian-io
json_metadata{"tags":["utopian-io"],"users":["yokunjon"],"app":"steemit/0.1"}
created2018-10-17 05:22:27
last_update2018-10-17 05:22:27
depth2
children0
last_payout2018-10-24 05:22:27
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length158
author_reputation2,727,533,211,976
root_title"Fully step by step guide how to debug php by vim+vdebug and xdebug"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,457,606
net_rshares10,007,704,124
author_curate_reward""
vote details (1)
@utopian-io ·
Thank you for your review, @yokunjon!

So far this week you've reviewed 8 contributions. Keep up the good work!
👍  
properties (23)
authorutopian-io
permlinkre-re-alanzheng-how-to-debug-php-by-vim-vdebug-and-xdebug-20181016t161846208z-20181021t121523z
categoryutopian-io
json_metadata"{"app": "beem/0.20.1"}"
created2018-10-21 12:15:24
last_update2018-10-21 12:15:24
depth2
children0
last_payout2018-10-28 12:15:24
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length111
author_reputation152,955,367,999,756
root_title"Fully step by step guide how to debug php by vim+vdebug and xdebug"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id73,745,667
net_rshares9,863,473,853
author_curate_reward""
vote details (1)