How to debug that PHP when it loads huge files?

Hello guys,
I started working at an enterprise that uses a lot XML data as inproper imports from other suppliers. About 90% of employees use Linux as their working environment and aren't not familiar with Windows at all (yeah, I know, sounds great to be perfect at Linux Distro). For me it's a problem and I need to setup my environment to reflect theirs to be consistent. One good thing that their development environment is Dockerized (they use Docker Compose) to build the CMS which they're working on as a MVC structure. Since each controller invoked in index file by the URL request, there is no big issue to start import script (which downloads XML via FTP or HTTP connection) and starts importing that XML to the database. These files are not so small and their're different depending on supplier and my task is to expand existing scripts (classes) that do such imports to transform XML data to our own environment to be able to store it in the database for managers to use later on.
Since it's all written in PHP and Dockerized, I setup my environment like this:
Installed Microsoft Windows 10x64 PRO as my host machine, then on the top of that I installed VirtualBox and Vagrant, vooted VM Ubuntu 18.4, to be exact it's hashicorp/bionic64 box. On that Vm I installed Docker, Docker- Compose and built their Dockerized system as a Docker Compose container on the top. So as you see there are 3 different layers here (host + guest + VM as Docker on VM). They helped me with that Dockerized system and installed it for me.
That Docker container performs function of a server that servers CMS that I mentioned. So I can use browser on my host OS and browse in that CMS. Vagrant does folder sharing / syncing project directory in which there's a docker ant cms folders and this way I can reach them from my Host, from VM and from Docker Compose when rebuilding CMS.
Now on to the problem:
When we simply enter URL in browser's address bar, PHP script starts and executes code line by line, _expression_ by _expression_ from start till the end. Since import scripts handle big files, it takes a long time one script to do it's dirty work and somewhere on the way it might crash because of wrong XML syntaxe, wrong elements or their values being set and my job to fix that. I can use die() function to break code at some point in the code, but then it requires to be reloaded and spins from the start again so takes a lot of precious time, so var_dump() and other PHP functions are out of the question here, because the point that all of them require script to be reloaded.
Now I need some kind of debugging and PHP has one, which I used in the past called XDebug. Their Dockerized system has XDebug as well and settings are set that it's exposed via port 9001 on their config, so it's possible to use an IDE and it's own terminal to debug all the scripts that are served, I mean we can run them through CLI and get an output, as well as set a debugging mechanism. But all they use only 2 layers of systems, I mean Linux on their hardrive and VM as a Docker Compose / VM on the top of that so they can connect to the XDebug from an IDE on Linux and debug. IDEs on Linux aren't accessible with Orca as far as I know and my productivity would be decreased fairly in browsing and doing all the stuff on Linux not because it's terminal, but because of it's GUI and screen reader of course.
Since the same HTTP request goes on the web and import process is working smoothly through web interface, I thaught to debug by using XDebug Helper extension on Google Chrome and VScode would be a saviour here, because it supports PHP Debug and has good screen reader support. So I thaut if I would set the same port for VSCode to listen for XDebug and it would be the same as a port in Dockerized VM (they set 9001), enter an url for a script to be executed in the browser that has XDebug Helper enabled and VSCODE set as an IDE key, script would load and VSCode would get the connection and would stop that code execution where I set up my breakpoints. That way I could debug it and it should work that way, but it just doesn't work...
I set my port forwarding in vagrantfile as such:
config.vm.network "forwarded_port", guest: 80, host: 8081
config.vm.network "forwarded_port", guest: 9001, host: 9001
config.vm.network "forwarded_port", guest: 80, host: 8081, host_ip: "127.0.0.1"
config.vm.network "private_network", ip: "192.168.33.10"
config.vm.network "public_network"
Then in C:\windows\system32\drivers\etc\hosts file I redirected 192.168.33.10 to that CMS which is on Docker, so it opens in the browser smoothly.
After that I changed the options in my VSCode project which is on c:\users\just\projects\project\cms. In that project folder is vagrantfile, so my guest OS sees the tvs folder and in the same root vagrant folder is docker folder as well. As far as I was saying, I changed c:\users\just\projects\project\tvs\.vscode\launch.json file and added this:
{"name": "Listen for Xdebug",
   "type": "php",
     "pathMappings": {
"/var/www/cms": "c:\\users\\just\\projects\\project\\cms"
  },
   "request": "launch",
   "port": 9001,
   "log": true}]
Then in VSCode I opened my project, chose index.php file which is at c:\users\just\projects\project\cms\web\index.php, set the breakpoint with f9, pressed f5 to run debugger, opened my browser, entered http://cms/ and it loaded index.php file, but it wasn't stopped by VSCode. When I turn on VSCode debugger, it says this:
<- launchResponse
Response {
  seq: 0,
  type: 'response',
  request_seq: 2,
  command: 'launch',
  success: true
};
But in fact - nothing happens. I'm sure that XDebug Helper is turned on in browser, also I'm sure that XDebug is selected i VSCode as a default launcher.
Maybe someone has some idea what's happening?

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : arbuz via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : arbuz via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : arbuz via Audiogames-reflector

Reply via email to