This repository has been archived by the owner on Jul 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from craftcms/feature/xdebug-setup-edits
Spiff up Xdebug PhpStorm setup instructions.
- Loading branch information
Showing
1 changed file
with
23 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
# Using Xdebug with Nitro and PhpStorm | ||
|
||
Once you have a machine created, you can run `nitro xdebug on` and `nitro xdebug configure` to enable Xdebug and set it up for automatic remote connections from your host machine. These make the | ||
Once you’ve created a machine, you can run `nitro xdebug on` and `nitro xdebug configure` to enable [Xdebug](https://xdebug.org/) and set it up for automatic connections from your host machine. | ||
|
||
## Debugging web requests | ||
You can use `nitro xdebug off` to disable Xdebug without having to restart the machine. | ||
|
||
Install the Xdebug browser helper in your favorite browser. | ||
## Configuring PhpStorm | ||
|
||
- [Chrome](https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc) | ||
- [Firefox](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/) | ||
- [Internet Explorer](https://www.jetbrains.com/phpstorm/marklets/) | ||
- [Safari](https://github.com/benmatselby/xdebug-toggler) | ||
- [Opera](https://addons.opera.com/addons/extensions/details/xdebug-launcher/) | ||
|
||
Go to the Xdebug browser helper options, choose "PhpStorm" and save. | ||
|
||
 | ||
|
||
Create a new server in PhpStorm using your machine's domain name. | ||
First, you’ll need to configure PhpStorm to listen for requests from the browser or console. | ||
|
||
1. Create a new server in PhpStorm using your machine’s domain name. (“Preferences” → “Languages & Frameworks” → “PHP” → “Servers”.) | ||
 | ||
|
||
Setup path mappings to that `/app/sites/example.test` in your Nitro machine is | ||
mapped to your project's root on your host machine. | ||
2. Enable “Use path mappings” and set your existing project root to the absolute path on the server. The absolute path will look like `/home/ubuntu/sites/my-site`, where `my-site` reflects your actual project’s folder name in the Nitro machine. (Use `nitro context` if you need to check the path, and keep in mind this is the project root and not necessarily the web root.) | ||
|
||
Create a new "PHP Remote Debug" configuration and select the server you just created. | ||
3. Choose “Run” → “Edit Configurations...” and create a new “PHP Remote Debug” configuration, selecting the server you just created. Check “Filter debug connection by IDE key” and enter `PHPSTORM`. | ||
 | ||
|
||
Check "Filter debug connection by IDE key" and enter "PHPSTORM" for the IDE key. | ||
4. Choose “Run” → “Start Listening for PHP Debug Connections”. | ||
 | ||
|
||
 | ||
## Debugging Web Requests | ||
|
||
Click the "Start Listening for PHP Debug Connections" button in PhpStorm. | ||
1. Install the Xdebug helper in your favorite browser. | ||
|
||
 | ||
- [Chrome](https://chrome.google.com/extensions/detail/eadndfjplgieldjbigjakmdgkmoaaaoc) | ||
- [Firefox](https://addons.mozilla.org/en-US/firefox/addon/xdebug-helper-for-firefox/) | ||
- [Internet Explorer](https://www.jetbrains.com/phpstorm/marklets/) | ||
- [Safari](https://github.com/benmatselby/xdebug-toggler) | ||
- [Opera](https://addons.opera.com/addons/extensions/details/xdebug-launcher/) | ||
|
||
Click the "Debug" button on your browser's Xdebug helper. | ||
2. In the browser helper’s options, choose “PhpStorm” and save. | ||
 | ||
|
||
3. Choose “Debug” on your browser’s Xdebug helper. | ||
 | ||
|
||
Then load the site in your browser and whatever breakpoints you've set will be hit. | ||
4. Load the site in your browser and whatever breakpoints you’ve set will be hit. | ||
|
||
## Debugging PHP console requests | ||
## Debugging Console Requests | ||
|
||
Do everything above except Xdebug browser helper. SSH into your Nitro machine using | ||
`nitro ssh`, then run your PHP script from the console and any breakpoints you've | ||
set will be hit. | ||
SSH into your Nitro machine using `nitro ssh`, then run your PHP script from the console and any breakpoints you’ve set will be hit. |