Starting a new project in Laravel. Using the latest WSL2 under Win10 v2004 (Apr 2020) instead of Homestead. It's all working great. Now I am brave enuf to want PHP breakpoints with Xdebug. I have installed Xdebug in Ubuntu 20 in the WSL.
~/STGdev/lv $ php -v
PHP 7.4.3 (cli) (built: May 26 2020 12:24:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.0-dev, Copyright (c) 2002-2020, by Derick Rethans
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
I'm not able to get any breakpoints to work. The big question is this --- does the vs code Xdebug extension use the Ubuntu PHP or does it require that I install an XAMPP PHP on under Windows? The instructions imply that either can be used?
You have two options to enable debugging:
My recommendation is using the WSL Extension method.
Keep in mind if you decided to use the Extension method, there will be a problem regarding Git not recognizing modified files correctly
You have XDebug 3 installed. Version 3 of Xdebug changed the way you need to configure is's settings. The most important breaking change is that the listening port now is 9003 instead of 9000. This is the php.ini configuration in my localhost for Xdebug 3 (it should work anywhere):
[xdebug]
zend_extension="C:\xampp\php\ext\php_xdebug-3.0.4-7.4-vc15-x86_64.dll"
xdebug.mode=develop,debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request=trigger
Change the path to your Xdebug extension and you should be able to debug your code now.
You don't need to install XAMPP, all settings are managed by your WSL with installed PHP. I have a Laravel project with docker using WSL2 (Ubuntu 20) in Windows 10 21H2 and here is my settings to make xdebug work. I use Xdebug 2.9.8, there're some changes of text in xdebug.ini, but most of them are same.
PHP 7.1.33 (cli) (built: Nov 22 2019 18:34:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
xdebug.ini
xdebug.remote_enable = On
xdebug.remote_autostart = On
xdebug.remote_connect_back = Off
xdebug.remote_host = "host.docker.internal"
xdebug.remote_port=9009
Dockerfile
FROM php:7.1-fpm
RUN pecl install xdebug-2.9.8 \
&& docker-php-ext-enable xdebug
COPY xdebug.ini /usr/local/etc/php/conf.d/
Docker-compose.yml
services:
webapp:
working_dir: /var/www/html
volumes:
- ./my-project-folder:/var/www/html
Move in to your project folder, typecode .
to open projet with WSL and then create debug file (launch.json): (enable your PHP Xdebug extension inside WSL by click on extenstion and choose 'enable')
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9009,
"pathMappings": {
"/var/www/html": "${workspaceFolder}"
}
Docker-compose.yml
extra_hosts:
- "host.docker.internal:host-gateway"
VS Code's launch.json
"hostname": "0.0.0.0",
That's all. 2nd method is much faster than 1st method in my experience.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
HTML (English "hyper text markup language" - hypertext markup language) is a special markup language that is used to create sites on the Internet.
Browsers understand html perfectly and can interpret it in an understandable way. In general, any page on the site is html-code, which the browser translates into a user-friendly form. By the way, the code of any page is available to everyone.
https://www.w3.org/html/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.