D10 Debugging - pierregermain/MyDrupal GitHub Wiki
FIRST: HAVE A LOOK AT docker-compose.json: You need a image with -dev

Important: Configure CLI Interpreter (The name "web" is important). You need to import using: Add from Docker, SSH, Docker Compose, Vagrant > Docker Compose




To know the server url do: docker-compose exec web pwd


Build, Execution, Deployment

$ alias dcdrush='docker-compose exec web ./vendor/bin/drush '
$ dcdrush status
Drupal version : 10.2.4
Site URI : http://web:8080/build
DB driver : mysql
DB hostname : mysql
DB port : 3306
DB username : root
DB name : ...
Database : Connected
Drupal bootstrap : Successful
Default theme : olivero
Admin theme : claro
PHP binary : /usr/bin/php8.1
PHP config : /etc/php/8.1/cli/php.ini
PHP OS : Linux
PHP version : 8.1.27
Drush script : /var/www/html/vendor/bin/drush
Drush version : 12.4.4.0
Drush temp : /tmp
Drush configs : /var/www/html/vendor/drush/drush/drush.yml
/var/www/html/build/drush/drush.yml
Install profile : minimal
Drupal root : /var/www/html/build
Site path : sites/default
Files, Public : sites/default/files
Files, Private : sites/default/files/private
Files, Temp : /tmp
$ docker-compose exec -e XDEBUG_SESSION=1 web ./vendor/bin/phpunit ./build/modules/custom/(...)/CorporateCountriesFilterTest.php
Test only a single function
phpunit --filter myCustomfunction MyClass.php
In macOS if you configured a bad IP:
MYIP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}')
docker-compose exec -e XDEBUG_CONFIG="client_host=$MYIP" -e XDEBUG_SESSION=1 web ./vendor/bin/phpunit ./tests/src/ExistingSite/InteractiveMapTest.php
In linux
export MYIP=$(ip route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q')
echo $MYIP
$ docker-compose exec -e XDEBUG_MODE=debug -e XDEBUG_CONFIG="client_host=$MYIP" -e XDEBUG_SESSION=1 web ./vendor/bin/phpunit
public function debugToFile($content = '') {
$file_path = '/var/www/html/web/sites/default/files/debug.html';
$file_path_txt = '/var/www/html/web/sites/default/files/debug.txt';
$file_data = "<pre>" . date("F j, Y, g:i a")
. " </pre><pre> " . (string) $content
. " </pre>" . $this->getCurrentPageContent();
//$file_data = file_get_contents($file_path) . $file_data;
file_put_contents($file_path, $file_data);
file_put_contents($file_path_txt, $file_data);
}
Press Threads:
