3

Following the instructions here, and I am stuck at the silliest of steps..

make a simple test.php file, put a phpinfo(); statement in there, then copy the output and paste it into the XDebug installation wizard.

I have created the the test.php file (with phpinfo(); as the only statement ), but I can't run it...

What I have done:

I have installed XAMPP, and started Apache on port 8080. http://localhost:8080/ gets me the XAMPP dashboard, so I know that is ok

I have "php.validate.executablePath": "C:/xampp/php/php.exe" in my settings.json

I have a tasks.json build task as follows

{
 "version": "0.1.0",
 "command": "php",
 "args": [
  "-S", "127.0.0.1:8080",
  "-t", "${workspaceRoot}"
 ]
}

but when I try to run it, I get an error

Failed to launch external program php -S 127.0.0.1:8080 -t ${workspaceRoot}.
spawn php ENOENT

Is my whole approach (gleaned from various guides on the web) somehow wrong, or what have I missed out? (I am a 20+ years MS dev, but I know zero about php, so sorry if it is a really daft question)

2 Answers 2

1

OK, so I managed a workaround, to at least display the test.php file.

Followed the instructions here, but the only way to have multiple sites that I found to work was using separate ports. So I added to C:\xampp\apache\conf\extra\httpd-vhosts.conf :

<VirtualHost *:8080>
    DocumentRoot "C:/xampp/htdocs/"
    ServerName localhost:8080
</VirtualHost>


<VirtualHost *:8081>
    DocumentRoot "C:/mydir/myrootfolder/"
    ServerName localhost:8081
</VirtualHost>

and to C:\xampp\apache\conf\httpd.conf, I added

<Directory />
    AllowOverride none
    Require all granted
</Directory>

and

Listen 8080
Listen 8081

My test.php file was amended to:

<?php
  phpinfo();
?>

I could then navigate to http://localhost:8081/test.php and see the output!

I hope this helps someone else, at least with this stage of the process. I will update if there's anything extra in actually setting up php-debug or x-debug itself.

Sign up to request clarification or add additional context in comments.

Comments

1

Run in console php -i or php -i > phpinfo.txt. Copy content output or content phpinfo.txt to Xdebug Wizard

Download .dll file from this page. And follow instruction. Add to php.ini, for example

[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.4.1-5.6-vc11.dll
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=on
xdebug.remote_handler=dbgp
xdebug.profiler_enable=1
xdebug.profiler_output_dir="C:\xampp\tmp"
xdebug.remote_log ="C:\xampp\tmp\xdebug.log"

Restart your Apache server. In browser in phpinfo() you see section with Xdebug setting. Else you are something wrong. In Visual Studio code in gebug panel push icon with gear and select php.

Created launch.json. In gebug panel selected Listen for Xdebug. Run debug.

Mark breakpoints in app. Navigate and reload app in browser.

Settings for mysite.local/test.php

Create folder "c:/[path-to-xampp]/htdocs/mysite.local" In this folder create file test.php

<?php
  phpinfo();
?>

Create new virtual host

<VirtualHost *:80>
ServerName mysite.local
DocumentRoot "c:/[path-to-xampp]/htdocs/mysite.local"
<Directory />
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
   Require all granted
   Allow from all
</Directory>
</VirtualHost>

In file C:/windows/system32/drivers/etc/hosts add

127.0.0.1 mysite.local

Restart your apache server. Navigate your app in browser: http://mysite.local

1 Comment

I will be adding to this later - because I have been through this process (unsuccessfully) already - but, just to ensure I give the right information ...if I follow your virtual host / hosts instructions, what should be the url to access the site from the browser?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.