Coder Social home page Coder Social logo

angristan / php-xdebug-docker Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 13.0 2 KB

Debug PHP with Xdebug inside Docker. Tested with PhpStorm and VS Code.

Home Page: https://stanislas.blog/debug-php-docker-xdebug-vscode-phpstorm/

Dockerfile 92.41% PHP 7.59%
php xdebug docker vscode phpstorm

php-xdebug-docker's Introduction

PHP/Xdebug/Docker example

Debug PHP with Xdebug inside Docker. Tested with PhpStorm and VS Code.

Usage

The Xdebug config happens in the Dockerfile. I recommend to look at it, escpeially the comments. The most important part is the xdebug.remote_host which has to be set to the Docker host.

A sample docker-compose.yml comes along with it so you can get this up and running in one command: docker-compose up --build -d.

VS Code configuration

Install the felixfbecker.php-debug extension.

You can create a debug configuration by going to Debug > Add Configuration... > PHP, but I've included the .vscode/launch.json file in the repo, with the correct folder maping.

Add a breakpoint, and click on "Listen for XDebug" in the top left hand corner. Load your page, and you should get debugging information:

PhpStorm configuration

You should not have to configure anything since we use the default debug port etc.

Add a breakpoint and start listening for Xdebug in the top right hand corner:

Load your page. PhpStorm will prompt you to add a "server" with a folder mapping:

And then magic happens:

Enjoy 👋

php-xdebug-docker's People

Contributors

angristan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

php-xdebug-docker's Issues

Document root is /var/www/html/public

Hello,

i will modify the start point of the apache.

in the Dockerfile i set:

´´´
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/.conf
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/
.conf
´´´
In the /etc/apache2/sites-available/*.conf there is no correct Document Root.

What is wrong.

Your sincerly

Stephan

Error: listen EADDRINUSE :::9000

I've followed your tutorial but it didn't work here. I've got the error:

{ Error: listen EADDRINUSE :::9000
    at Server.setupListenHandle [as _listen2] (net.js:1286:14)
    at listenInCluster (net.js:1334:12)
    at Server.listen (net.js:1421:7)
    at Promise (/home/victor/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/phpDebug.js:236:24)
    at new Promise (<anonymous>)
    at createServer (/home/victor/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/phpDebug.js:184:40)
    at PhpDebugSession.<anonymous> (/home/victor/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/phpDebug.js:240:27)
    at Generator.next (<anonymous>)
    at /home/victor/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/phpDebug.js:7:71
    at new Promise (<anonymous>)
  errno: 'EADDRINUSE',
  code: 'EADDRINUSE',
  syscall: 'listen',
  address: '::',
  port: 9000 }

Do you know the reason of it?

document root for apache

Hello,

in my projet there are same directory.

public/index.php
public/javascript/
public/css/

src/action/
src/model/
src/service/

How can i set the document root of the apache ?
I will start always with /public/index.php

Can i use a .htaccess file for my css files under /public/css

Your sincerly

Stephan

Breakpoint is not triggering

Steps:

  • Checkout the project
  • docker-compose up --build -d on the terminal.
  • Run XDebug from VSCODE

Browsers I've tried: Chrome/Safari/Firefox

When I loaded website, phpinfo shows

xdebug.client_host | localhost | localhost
-- | -- | --
xdebug.client_port | 9003 | 9003

xdebug not starting

Hello, I tried to follow your configs and couldn't make this work. The debug console is clear and the code isn't stoping at break points. I just cloned your repo and followed your structions. Do you have any ideia?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.