[Solved] Configure PhpStorm with Xdebug and XAMPP?

  

4
Topic starter

Hi, I want to learn PHP.

I am beginner and I need to know how to use and configure PhpStorm IDE with XAMPP (Apache server and MySQL DB) and Xdebug (I need integration for debugging purposes)?

Thanks

2 Answers
3

First you need to install and configure XAMPP and integrate it with PhpStorm (4 steps):

1. Download XAMPP last version from https://www.apachefriends.org/download.html .

I use version 7.2.9 (not the latest):

xampp for Windows

2. Install XAMPP in the default directory C:\xampp, or you might encounter permission troubles later on.

3. The first time you start XAMPP you will get language selection screen. After you choose the language you prefer, you will see the main screen of XAMPP.

4. Now you need to start the Apache server. If everything is correct, the Apache label will become green, and you will see the default ports – 80. If you have Skype or a torrent client running, the Apache server will not start. You need to exit the program that holds port 80, and the Apache server will start.

Now, you need to connect the Debugger (Xdebug), Apache Server and MySQL DB (XAMPP) to PhpStorm:

5. If you have started PhpStorm before, you need to either close your current project using File -> Close Project option or simply skip this step and go to File -> Default Settings.

You should see this screen:

settings PHPSto

As you can see in the picture, you need to go to the settings menu.

6. Once we are in the settings menu you need to go to Languages & Frameworks tab and select PHP. You need to change the PHP version to your installed PHP version:

phpstorm settings 2

After that you need to change the PHP Interpreter. On the default interpreters page, you need to click the green plus and press Local Path to Interpreter. You need to choose the PHP Executable now. In order to do that, you need to find your XAMPP folder and choose the "php" directory and in it select php.exe;

If everything is alright, you should see this:

phpstorm settings 4

7. Create PHP Debugger Configuration

You need to download Xdebug debugger from here: https://xdebug.org/files/php_xdebug-2.6.0-7.2-vc15.dll .
 
Place the downloaded file to "C:\xampp\php\ext".
 
Now you need to edit the php configuration. Open the php.ini file located in "C:\xampp\php\php.ini".
 
Once you open the file add the following lines:
[Xdebug]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.6.0-7.2-vc15.dll"
xdebug.remote_enable = 1

Restart XAMPP and run the Apache and MySQL modules again.

If you’ve done everything correctly, you should see the following screen:

phpstorm settings 5

Before configuring the debugger, you need to return to the home screen and create new project. Then you need to choose Empty PHP project and make sure that the location of the project is in htdocs folder in XAMPP. 

phpstorm xdebug

After that you need to create a new php file inside your project. For example index.php; 

After that edit the configuration:

phpstorm xdebugChoose a PHP Web Page (On old PHPStorm version it might be called PHP Web Application) on the drop down after you click the green plus.

Edit the Configuration Name and add new server. Add new server with Host = localhost, on port 80 with Xdebug debugger:

xdebug phpstorm settings

At last you need to select the newly created server, and edit the URL. In the URL part you need to locate the file that you want to debug starting from localhost. In the example below my file is in project HelloWorld with file name index.php.

debugger phpstorm

The result should be the following:

xdebug configuration php storm

Now you are ready to start using PHP! 🙂

1

You can use this site: https://xdebug.org/wizard for the Xdebug integration

Share: