PHP - Cli, Xdebug, Docker, And Vscode
Hi y'all. I've been scrubbing Google for this and from everything I'm reading and seeing, this should be working - problem is it's not... Here's the deal. I've got a docker image spun up with my development environment and all that's fine. I've updated the php.ini on the image with the following: [xdebug] xdebug.remote_autostart=1 xdebug.remote_enable=1 xdebug.remote_log="/var/log/xdebug.log" xdebug.remote_host=host.docker.internal xdebug.remote_handler=dbgp xdebug.remote_port=9000 xdebug.remote_connect_back=0 xdebug.collect_vars=1 xdebug.collect_returns=1 xdebug.collect_assignments=1 xdebug.profiler_enable=1 xdebug.idekey=VSCODE I created a new config in launch.json as so: { "name": "Remote XDebug", "type": "php", "request": "launch", "port": 9900, "pathMappings": { "/var/www/html" : "${workspaceRoot}/myDir" }, "cwd": "${workspaceRoot}/myDir" } I set a few breakpoints in VSCode in my file on the host system, start the debugger, and docker-compose run into the image, where I `php test.php` and expect to be brought into the debug session as I would on the host system (that part works). However, it doesn't happen - I never get into the debug session on the host system. My xdebug.log does, however, look like everything should be working: [11] Log opened at 2020-05-04 20:37:03 [11] I: Connecting to configured address/port: host.docker.internal:9000. [11] I: Connected to client. :-) [11] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///var/www/html/testing/test.php" language="PHP" xdebug:language_version="7.1.33" protocol_version="1.0" appid="11" idekey="VSCODE"><engine version="2.9.1"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init> [11] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response> [11] Log closed at 2020-05-04 20:37:03 Oh, and my docker-compose file maps port 9900 on the host to 9000 image. service: build: context: '.' volumes: - ../myDir/:/var/www/html/ - ../logs/:/var/log/ ports: - 80:80 - 443:443 - 9900:9000 networks: - test environment: - ENVIRONMENT=development depends_on: - database Anybody have any ideas? I'm just burning time on this now, but I'd very much like to be able to debug in the docker container because I'm currently working with a couple different companies that use wildly different php/server setups and I don't want to have to try and keep that straight or have to continually nuke my machine. Thanks in advance! Edited May 4, 2020 by maxxdSimilar TutorialsHi i am trying to use xdebug 2.1.0, i have installed it on linux wth php version 5.2.5, Can any one tell me the correct php version for 2.1.0 this . What is this phpize and php-config tools.....where to find and how........tell some examples to use xdebug. Thanks, This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=354998.0 Hi all. Does anyone use Localstack to for local AWS development? I'm currently developing on a system that uses numerous AWS SQS queues, AWS ElasticSearch, AWS Redis, and many, many S3 buckets with about three dozen PHP-based micro-services; I've built a local development environment consisting of containers using several Docker images, one of which mocks AWS using a Localstack image. This works, for the most part, but I find that the Localstack instance just ... stops working. It - after a random amount of time, and intermittently if more often than not - won't process any of the queues that the system uses, or will drop bucket contents despite being set up for persistence (the `DATA_DIR` objective is set to `/tmp/localstack/data` as instructed in the README). I get the impression that Localstack is fairly widely used for local AWS development, so I have to assume if this was a normal situation I'd've found it in my searching, but so far it doesn't seem to be a big deal. I'll post the docker-compose file here if it helps, but does anyone have any experience with a similar situation and feel like sharing tips? Did it work, did it not, do I need to convince my company to pay for the pro version, do I need to do a modified rain dance, etc? As always, thanks in advance for any thoughts or advice. Hey y'all. I'm not sure which sub-forum is most appropriate for this question, so I'm putting it here because here's where I go first. Anyway - does anybody use mkcert with Docker? It seems like a perfect solution to enable local SSL-enabled development and testing, but I'm still getting the 'Potential Security Risk' warning when I hit my local dev site. The problem is that the system I'm working on now is all about php-based "micro-services" that talk to each other via AWS SQS queues, and some (one in particular) are throwing an "Unknown SSL protocol error" when using a super old version of the AWS PHP API to move a file into an S3 bucket hosted on my localstack environment. It's not helped by the fact that I have to mix php 7.2 and 5.6 in separate docker containers in this image to get everything to play mostly OK with each other. Sorry for the rambling - it's late. My question is this: what am I missing in my mkcert setup that I'm still getting the authentication error in the browser? This is what I've got specific to this issue (I've installed wget and libnss3-tools and my image is based on php:7.4-apache: Dockerfile: # create the locally trusted SSL certificates RUN mkdir /usr/local/.ssh RUN wget https://github.com/FiloSottile/mkcert/releases/download/v1.4.1/mkcert-v1.4.1-linux-amd64 RUN mv mkcert-v1.4.1-linux-amd64 mkcert RUN chmod +x mkcert RUN cp mkcert /usr/local/bin/ RUN mkcert -install RUN mkcert -cert-file /usr/local/.ssh/laravel-local.pem -key-file /usr/local/.ssh/laravel-local-key.pem '*.laravel.local' laravel.local localhost 127.0.0.1 Apache.conf: <VirtualHost *:80> ServerAdmin webmaster@localhost.com DocumentRoot "/var/www/html/public" ServerName "laravel.local" <Directory "/var/www/html/public/"> AllowOverride All </Directory> </VirtualHost> <VirtualHost *:443> DocumentRoot "/var/www/html/public" ServerName "laravel.local" SSLEngine On SSLCertificateFile "/usr/local/.ssh/laravel-local.pem" SSLCertificateKeyFile "/usr/local/.ssh/laravel-local-key.pem" </VirtualHost> docker-compose: laravel: build: context: . image: laravel:new volumes: - ../project:/var/www/html - ../logs/:/var/log/ ports: - 8001:80 - 443:443 environment: - ENVIRONMENT=development networks: - laravel Obviously there's more to each of the files, but I've included the pertinent parts - let me know if more would be helpful. |