Visual Studio Code Laravel



Debugging: Configure Xdebug + Laravel Homestead + VS Code + PHPUnit

Visual Studio Code is an amazing code editor, one of my favorites next to Atom and Sublime Text. Laravel is my favorite when it comes to enterprise PHP development. In this article, let me show you.

After receiving some great feedback on my post, Debugging: Configure VS Code + Xdebug + PHPUnit, I had a few people ask me for some help configuring their Xdebug setup on their Laravel Homestead environments. Adding a virtual machine to the mix does add a bit of complexity, but the benefit of having a proper debugging environment far outweighs the initial legwork.

The following assumes that you have already installed Homestead for your project.

Enable Xdebug in Homestead

  • Code’s built-in terminal is so useful, but it takes up valuable space in your editor. By default, you can focus and hide it with this shortcut key: cmd+backtick. That key hurts my wrist, so I use cmd+t instead. Note: Code’s default implementation of toggling the terminal is silly.
  • SoengSouy.Webdesign Is a free online learning program that introduces methods and how to coding websites from the limit First, to the highest level.
  • Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, and caching.
  • Maps for your Laravel application. Skip to content. Download source code. Zip tar.gz tar.bz2 tar. Clone Clone with SSH Clone with HTTPS Open in your IDE Visual.

1. SSH into your homestead machine:

2. Enable Xdebug with Homestead's xon command:

3. Find your guest machine's gateway IP. This will be the IP Address that your guest machine can use to communicate with your host machine

The output I see on my Homestead machine is 10.0.2.2; just remember this for the next step.

4. Local xdebug.ini, the Xdebug config file:

My output shows the ini file at /etc/php/7.1/cli/conf.d/20-xdebug.ini

5. Configure Xdebug to use the gateway as the xdebug.remote_host value:

Edit the xdebug.ini file you just located: Remote desktop web client microsoft.

Visual Studio Code Laravel Plugin

And make sure the settings are set like this, appropriately for your gateway IP:

7. Restart the PHP-FPM service

Visual Studio Code Laravel Debug

Visual studio code laravel

VSCode Setup

1. Install the PHP Debug plugin

2. Open the debug panel

3. Click on the 'config' button (the cogwheel) and select PHP

4. Modify the default launch.json file:

Make sure to edit this file for your correct localSourceRoot and serverSourceRoot:

Here, we are adding a new configuration object that is the same as Listen for Xdebug, but we include the pathMappings values per the plugin's documenatation on Remote Host Debugging.

5. Open a PHPUnit test file and set a breakpoint using the debugger plugin.

6. Set the debugger to 'Listen for XDebug on Homestead'.

7. 'Start Debugging' by clicking on the green arrow button.

Download citrix for mac os x. This doesn't actually start the debugging process; instead, it starts a listener that will be triggered once you run the PHPUnit test.

You should now see a step toolbar with the blue arrow buttons greyed out:

Debug!

You're now ready to run your test from within your Homestead virtual machine:

The Zyxel IPSec VPN Client is designed an easy 3-step configuration wizard to help remote employees to create VPN connections quicker than ever. The user-friendly interface makes it easy to install, configure and use. With Zyxel IPSec VPN Client, setting up a VPN connection is no longer a daunting task. The Cisco VPN Client is available for both 32bit and 64bit Windows operating systems. To download the latest Cisco VPN Client, simply visit our download section and look for our new Cisco. Click Start, click Run, type mmc, and then click OK. Click Console, click Add/Remove Snap-in, click Add, click IP Security Policy Management, click Add, click Finish, click Close, and then click OK. Right-click IP Security Policies on Local Machine, click Create IP Security Policy, and then click Next. Cisco ipsec client linux

Visual Studio Code should display the first breakpoint, and the toolbar will allow you to step through your code.

A note on performance

Enabling Xdebug does come with a performance hit. If you no longer need to do any debugging, you can easily disable the Xdebug plugin by ssh-ing into your Homestead virtual machine and using the xoff command.

Visual Studio Code Laravel Plugin

Happy Debugging!!

Vs Code Intellisense

If this walkthrough has helped you get started with a proper debugging environment, or if you'd like to see a walkthrough for a specific environment, please hit us up on Twitter. We'd love to hear your feedback! Tweet @JoseCanHelp and @TightenCo.