-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from usabilla/feature/split-debug-conf
Improve development mode
- Loading branch information
Showing
8 changed files
with
138 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
expose_php=on | ||
|
||
opcache.validate_timestamps=1 | ||
|
||
zend.assertions=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,5 @@ | ||
expose_php=on | ||
|
||
opcache.validate_timestamps=1 | ||
|
||
xdebug.default_enable=0 | ||
xdebug.remote_enable=1 | ||
xdebug.remote_host=docker.for.mac.localhost | ||
xdebug.remote_host=host.docker.internal | ||
xdebug.remote_connect_back=0 | ||
xdebug.profiler_enable_trigger=1 | ||
|
||
zend.assertions=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
usage() { | ||
echo "usage: $0 COMMAND" | ||
echo | ||
echo "Turns PHP into development mode." | ||
echo "There's not option to revert it since this should only be executed for dev images or runtime debugging." | ||
echo | ||
echo "Commands:" | ||
echo " xdebug downloads, installs and enable xdebug in the container" | ||
echo " config adds standard development configuration for PHP" | ||
echo | ||
} | ||
|
||
case "$1" in | ||
xdebug) | ||
apkDel= | ||
if [ -n "$PHPIZE_DEPS" ]; then | ||
if apk info --installed .phpize-deps-configure > /dev/null; then | ||
apkDel='.phpize-deps-configure' | ||
elif ! apk info --installed .phpize-deps > /dev/null; then | ||
# shellcheck disable=SC2086 | ||
apk add --no-cache --virtual .phpize-deps $PHPIZE_DEPS | ||
apkDel='.phpize-deps' | ||
fi | ||
else | ||
>&2 echo "\$PHPIZE_DEPS env variable is necessary to run this script" | ||
exit 1 | ||
fi | ||
|
||
pecl install xdebug | ||
docker-php-ext-enable xdebug | ||
apk del $apkDel | ||
|
||
cp /usr/local/etc/php/conf.d/available/xdebug.ini /usr/local/etc/php/conf.d/zzz_xdebug.ini | ||
;; | ||
|
||
config) | ||
cp /usr/local/etc/php/conf.d/available/dev.ini /usr/local/etc/php/conf.d/zzz_dev.ini | ||
;; | ||
|
||
*) | ||
usage | ||
exit 1 | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import pytest | ||
|
||
@pytest.mark.php_dev | ||
def test_configuration_is_present(host): | ||
assert host.file('/usr/local/etc/php/conf.d/zzz_xdebug.ini').exists is True | ||
assert host.file('/usr/local/etc/php/conf.d/zzz_dev.ini').exists is True | ||
|
||
@pytest.mark.php_dev | ||
def test_configuration_is_effective(host): | ||
configuration = host.run('php -i').stdout | ||
|
||
assert u'expose_php => On => On' in configuration | ||
assert u'opcache.validate_timestamps => On => On' in configuration | ||
assert u'zend.assertions => 1 => 1' in configuration | ||
|
||
@pytest.mark.php_dev | ||
def test_xdebug_is_loaded(host): | ||
assert 'Xdebug' in host.run('php -m').stdout | ||
|
||
@pytest.mark.php_no_dev | ||
def test_configuration_is_not_present(host): | ||
assert host.file('/usr/local/etc/php/conf.d/zzz_xdebug.ini').exists is False | ||
assert host.file('/usr/local/etc/php/conf.d/zzz_dev.ini').exists is False | ||
|
||
@pytest.mark.php_no_dev | ||
def test_configuration_is_not_effective(host): | ||
configuration = host.run('php -i').stdout | ||
|
||
assert u'expose_php => Off => Off' in configuration | ||
assert u'opcache.validate_timestamps => Off => Off' in configuration | ||
assert u'zend.assertions => -1 => -1' in configuration | ||
|
||
@pytest.mark.php_no_dev | ||
def test_xdebug_is_not_loaded(host): | ||
assert 'Xdebug' not in host.run('php -m').stdout |