From 4c27cc5820217db9d964a59325592207fe554cea Mon Sep 17 00:00:00 2001 From: Alex Paliarush Date: Wed, 4 Apr 2018 17:41:59 -0500 Subject: [PATCH] Added PHP 7.2 support for Magento 2.3 #169 --- CHANGELOG.md | 2 +- README.md | 2 +- etc/config.yaml.dist | 2 +- .../configure_environment_recurring.sh | 6 +-- .../upgrade_environment_recurring.sh | 51 +++++++++++++++++-- 5 files changed, 54 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 116acc8edc2..b5d3ec359c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - - PHP 7.1 support + - PHP 7.1 and PHP 7.2 support - Support for new location of `generated` directory in Magento 2.2.0 - Basic data generation can be turned off. Added configurable product and customer address generation diff --git a/README.md b/README.md index 02313708489..f943b9df20a 100755 --- a/README.md +++ b/README.md @@ -287,7 +287,7 @@ See [draft](https://github.com/paliarush/magento2-vagrant-for-developers/issues/ ### Switch between PHP versions -Switch between PHP versions using "php_version: " option in [config.yaml](etc/config.yaml.dist). Supported versions are 5.6, 7.0 and 7.1. +Switch between PHP versions using "php_version: " option in [config.yaml](etc/config.yaml.dist). Supported versions are 5.6, 7.0, 7.1 and 7.2. PHP version will be applied after "vagrant reload". ### Activating Varnish diff --git a/etc/config.yaml.dist b/etc/config.yaml.dist index c91abf6a567..e83f3ce4740 100644 --- a/etc/config.yaml.dist +++ b/etc/config.yaml.dist @@ -33,7 +33,7 @@ guest: forwarded_ssh_port: 3000 environment: - # [To apply changes: vagrant reload] Valid versions: 5.6, 7.0, 7.1 + # [To apply changes: vagrant reload] Valid versions: 5.6, 7.0, 7.1, 7.2 php_version: "7.0" composer_prefer_source: 0 # [To apply changes: m-reinstall OR m-varnish enable/disable] diff --git a/scripts/provision/configure_environment_recurring.sh b/scripts/provision/configure_environment_recurring.sh index 79e81b5ed9e..63e234e5f1f 100755 --- a/scripts/provision/configure_environment_recurring.sh +++ b/scripts/provision/configure_environment_recurring.sh @@ -80,13 +80,13 @@ fi status "Setting up PHP" -php_ini_paths=( /etc/php/5.6/cli/php.ini /etc/php/7.0/cli/php.ini /etc/php/7.1/cli/php.ini ) +php_ini_paths=( /etc/php/5.6/cli/php.ini /etc/php/7.0/cli/php.ini /etc/php/7.1/cli/php.ini /etc/php/7.2/cli/php.ini ) process_php_config ${php_ini_paths} -if [[ ${php_version} == "5.6" ]] || [[ ${php_version} == "7.0" ]] || [[ ${php_version} == "7.1" ]]; then +if [[ ${php_version} == "5.6" ]] || [[ ${php_version} == "7.0" ]] || [[ ${php_version} == "7.1" ]] || [[ ${php_version} == "7.2" ]]; then status "Configuring PHP ${php_version}" update-alternatives --set php "/usr/bin/php${php_version}" - a2dismod php5.6 2> >(logError) > >(log) && a2dismod php7.0 2> >(logError) > >(log) && a2dismod php7.1 2> >(logError) > >(log) + a2dismod php5.6 2> >(logError) > >(log) && a2dismod php7.0 2> >(logError) > >(log) && a2dismod php7.1 2> >(logError) > >(log) && a2dismod php7.2 2> >(logError) > >(log) a2enmod "php${php_version}" 2> >(logError) > >(log) sed -i "s|xdebug.remote_connect_back=1|xdebug.remote_host=192.168.10.1|g" "/etc/php/${php_version}/cli/conf.d/20-xdebug.ini" else diff --git a/scripts/provision/upgrade_environment_recurring.sh b/scripts/provision/upgrade_environment_recurring.sh index e0ab67cc2fc..79c399f60da 100755 --- a/scripts/provision/upgrade_environment_recurring.sh +++ b/scripts/provision/upgrade_environment_recurring.sh @@ -100,9 +100,9 @@ function install_php71 () { # Install XDebug apt-get install -y php7.1-dev cd /usr/lib - rm -rf xdebug + rm -rf xdebug71 git clone git://github.com/xdebug/xdebug.git - cd xdebug + cd xdebug71 phpize ./configure --enable-xdebug make @@ -110,7 +110,7 @@ function install_php71 () { ## Configure XDebug to allow remote connections from the host mkdir -p /etc/php/7.1/cli/conf.d touch /etc/php/7.1/cli/conf.d/20-xdebug.ini - echo 'zend_extension=/usr/lib/xdebug/modules/xdebug.so + echo 'zend_extension=/usr/lib/xdebug71/modules/xdebug.so xdebug.max_nesting_level=200 xdebug.remote_enable=1 xdebug.remote_host=192.168.10.1 @@ -120,10 +120,55 @@ function install_php71 () { ln -s /etc/php/7.1/cli /etc/php/7.1/apache2 } +function install_php72 () { + status "Installing PHP 7.2" + + apt-get update + + # Setup PHP + apt-get install -y language-pack-en-base + LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php + apt-get update + + # Install PHP 7.2 + apt-get install -y php7.2 php7.2-curl php7.2-cli php7.2-mysql php7.2-gd php7.2-intl php7.2-xsl php7.2-bcmath php7.2-mbstring php7.2-soap php7.2-zip libapache2-mod-php7.2 + + # Install XDebug + apt-get install -y php7.2-dev + cd /usr/lib + rm -rf xdebug72 + git clone git://github.com/xdebug/xdebug.git + cd xdebug72 + phpize + ./configure --enable-xdebug + make + make install + ## Configure XDebug to allow remote connections from the host + mkdir -p /etc/php/7.2/cli/conf.d + touch /etc/php/7.2/cli/conf.d/20-xdebug.ini + echo 'zend_extension=/usr/lib/xdebug72/modules/xdebug.so + xdebug.max_nesting_level=200 + xdebug.remote_enable=1 + xdebug.remote_host=192.168.10.1 + xdebug.idekey=phpstorm' >> /etc/php/7.2/cli/conf.d/20-xdebug.ini + echo "date.timezone = America/Chicago" >> /etc/php/7.2/cli/php.ini + rm -rf /etc/php/7.2/apache2 + ln -s /etc/php/7.2/cli /etc/php/7.2/apache2 +} + + if [[ ! -d "/etc/php/7.1" ]]; then install_php71 fi +if [[ ! -d "/etc/php/7.2" ]]; then + install_php72 +fi + +# TODO: Fix for a bug, should be removed in 3.0 +sed -i "/zend_extension=.*so/d" /etc/php/7.0/cli/conf.d/20-xdebug.ini +echo "zend_extension=xdebug.so" >> /etc/php/7.0/cli/conf.d/20-xdebug.ini + status "Fixing potential issue with MySQL being down after VM power off" service mysql restart 2> >(logError) > >(log)