Skip to content

Commit 2a2099e

Browse files
authored
Merge pull request #609 from humanmade/enable-xdebug
Enable xdebug only when starting server with `--xdebug`
2 parents ecb29fa + 8d7dbd0 commit 2a2099e

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

docker/php.ini

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,3 @@
22

33
# Set sendmail to use mailhog.
44
sendmail_path = ${PHP_SENDMAIL_PATH}
5-
6-
# XDebug
7-
xdebug.mode = debug
8-
xdebug.start_with_request = yes
9-
xdebug.var_display_max_children = 1024
10-
xdebug.var_display_max_data = -1
11-
xdebug.var_display_max_depth = 10

docker/xdebug.ini

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# XDebug. Only loaded with local server is started with `--xdebug`.
2+
zend_extension=xdebug
3+
4+
[Xdebug]
5+
xdebug.mode = debug
6+
xdebug.start_with_request = yes
7+
xdebug.var_display_max_children = 1024
8+
xdebug.var_display_max_data = -1
9+
xdebug.var_display_max_depth = 10

inc/composer/class-docker-compose-generator.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ public function __construct( string $root_dir, string $project_name, string $tld
9898
*/
9999
protected function get_php_reusable() : array {
100100
$version_map = [
101-
'8.2' => 'humanmade/altis-local-server-php:8.2.3',
102-
'8.1' => 'humanmade/altis-local-server-php:6.0.5',
103-
'8.0' => 'humanmade/altis-local-server-php:5.0.4',
101+
'8.2' => 'humanmade/altis-local-server-php:8.2.5',
102+
'8.1' => 'humanmade/altis-local-server-php:6.0.7',
103+
'8.0' => 'humanmade/altis-local-server-php:5.0.7',
104104
'7.4' => 'humanmade/altis-local-server-php:4.2.5',
105105
];
106106

@@ -120,6 +120,17 @@ protected function get_php_reusable() : array {
120120

121121
$image = $version_map[ $version ];
122122

123+
$volumes = [
124+
$this->get_app_volume(),
125+
"{$this->config_dir}/php.ini:/usr/local/etc/php/conf.d/altis.ini",
126+
'socket:/var/run/php-fpm',
127+
'tmp:/tmp',
128+
];
129+
130+
if ( $this->args['xdebug'] !== 'off' ) {
131+
$volumes[] = "{$this->config_dir}/xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini";
132+
}
133+
123134
$services = [
124135
'init' => true,
125136
'depends_on' => [
@@ -148,12 +159,7 @@ protected function get_php_reusable() : array {
148159
"proxy:s3-{$this->hostname}",
149160
"proxy:s3-{$this->project_name}.localhost",
150161
],
151-
'volumes' => [
152-
$this->get_app_volume(),
153-
"{$this->config_dir}/php.ini:/usr/local/etc/php/conf.d/altis.ini",
154-
'socket:/var/run/php-fpm',
155-
'tmp:/tmp',
156-
],
162+
'volumes' => $volumes,
157163
'networks' => [
158164
'proxy',
159165
'default',

0 commit comments

Comments
 (0)