Skip to content

Commit

Permalink
Add PHP 7.1 and 7.2 support for Magento 2.3 #169
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Paliarush committed Apr 3, 2018
1 parent b157763 commit ffd8967
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 46 deletions.
17 changes: 9 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.require_version "~> 1.8"
Vagrant.require_version "> 1.8"

require 'yaml'

Expand Down Expand Up @@ -66,13 +66,14 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
end

shell_script_args = [
use_nfs_for_synced_folders ? "1" : "0", #1
guest_magento_dir, #2
magento_host_name, #3
config_data['environment']['use_php7'], #4
host_magento_dir, #5
OS.is_windows ? "1" : "0", #6
host_vagrant_dir #7
use_nfs_for_synced_folders ? "1" : "0", #1
guest_magento_dir, #2
magento_host_name, #3
config_data['environment']['use_php7'] || 0, #4 TODO: Remove legacy parameter, replaced with php_version
host_magento_dir, #5
OS.is_windows ? "1" : "0", #6
host_vagrant_dir, #7
config_data['environment']['php_version'] #8
]

config.vm.provision "fix_no_tty", type: "shell", run: "always" do |s|
Expand Down
4 changes: 2 additions & 2 deletions etc/config.yaml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ guest:
forwarded_ssh_port: 3000

environment:
# [To apply changes: vagrant reload] If set to 0, PHP 5 will be installed.
use_php7: 1
# [To apply changes: vagrant reload] Valid versions: 5.6, 7.0, 7.1
php_version: "7.1"
composer_prefer_source: 0
# [To apply changes: m-reinstall OR m-varnish enable/disable]
use_varnish: 0
Expand Down
97 changes: 61 additions & 36 deletions scripts/provision/configure_environment_recurring.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,44 @@ function process_php_config () {
sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path}
sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path}
sed -i "s|;always_populate_raw_post_data = -1|always_populate_raw_post_data = -1|g" ${php_ini_path}

# TODO: Fix for a bug, should be removed in 3.0
sed -i "s|:/vendor/phpunit/phpunit|:${guest_magento_dir}/vendor/phpunit/phpunit|g" ${php_ini_path}
fi
done
}

function init_php56 () {
status "Installing PHP 5.6"
add-apt-repository ppa:ondrej/php 2> >(logError) > >(log)
apt-get update 2> >(logError) > >(log)
apt-get install -y php5.6 php-xdebug php5.6-xml php5.6-mcrypt php5.6-curl php5.6-cli php5.6-mysql php5.6-gd php5.6-intl php5.6-bcmath php5.6-mbstring php5.6-soap php5.6-zip libapache2-mod-php5.6 2> >(logError) > >(log)
echo '
function install_php71 () {
status "Installing PHP 7.1"

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.1
apt-get install -y php7.1 php7.1-mcrypt php7.1-curl php7.1-cli php7.1-mysql php7.1-gd php7.1-intl php7.1-xsl php7.1-bcmath php7.1-mbstring php7.1-soap php7.1-zip libapache2-mod-php7.1

# Install XDebug
apt-get install -y php7.1-dev
cd /usr/lib
rm -rf xdebug
git clone git://github.com/xdebug/xdebug.git
cd xdebug
phpize
./configure --enable-xdebug
make
make install
## 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
xdebug.max_nesting_level=200
xdebug.remote_enable=1
xdebug.remote_host=192.168.10.1' >> /etc/php/5.6/mods-available/xdebug.ini
xdebug.remote_host=192.168.10.1
xdebug.idekey=phpstorm' >> /etc/php/7.1/cli/conf.d/20-xdebug.ini
echo "date.timezone = America/Chicago" >> /etc/php/7.1/cli/php.ini
rm -rf /etc/php/7.1/apache2
ln -s /etc/php/7.1/cli /etc/php/7.1/apache2
}

function isServiceAvailable() {
Expand All @@ -46,7 +68,19 @@ function isNodeJsInstalled() {
}

guest_magento_dir=$2
use_php7=$4
use_php7=$4 # TODO: Remove deprecated argument, php_version should be used instead
php_version=$8

# TODO: Remove support for deprecated argument use_php7
if [[ -z ${php_version} ]]; then
if [[ ${use_php7} -eq 1 ]]; then
php_version="7.0"
else
php_version="5.6"
fi
fi


vagrant_dir="/vagrant"

source "${vagrant_dir}/scripts/output_functions.sh"
Expand Down Expand Up @@ -81,29 +115,24 @@ else
fi

status "Setting up PHP"
php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini )

if [[ ! -d "/etc/php/7.1" ]]; then
install_php71
fi

php_ini_paths=( /etc/php/5.6/cli/php.ini /etc/php/7.0/cli/php.ini /etc/php/7.1/cli/php.ini )
process_php_config ${php_ini_paths}

if [[ ${use_php7} -eq 1 ]]; then
status "Configuring PHP 7"
update-alternatives --set php /usr/bin/php7.0
if [[ -d "/etc/php/5.6" ]]; then
a2dismod php5.6 2> >(logError) > >(log)
fi
sed -i "s|xdebug.remote_connect_back=1|xdebug.remote_host=192.168.10.1|g" /etc/php/7.0/cli/conf.d/20-xdebug.ini
a2enmod php7.0 2> >(logError) > >(log)
# 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
if [[ ${php_version} == "5.6" ]] || [[ ${php_version} == "7.0" ]] || [[ ${php_version} == "7.1" ]]; 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)
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
status "Configuring PHP 5.6"
if [[ ! -d "/etc/php/5.6" ]]; then
init_php56
fi
update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6 2> >(logError) > >(log)
rm -rf /etc/php/5.6/apache2
ln -s /etc/php/5.6/cli /etc/php/5.6/apache2
sed -i "s|xdebug.remote_connect_back=1|xdebug.remote_host=192.168.10.1|g" /etc/php/5.6/mods-available/xdebug.ini
error "PHP version specified in the etc/config.yam is not supported."
decrementNestingLevel
exit 1
fi
service apache2 restart 2> >(logError) > >(log)

Expand All @@ -118,11 +147,7 @@ if [[ ${is_elastic_search_installed} -eq 0 ]]; then
fi

status "Enabling email logging"
if [[ ${use_php7} -eq 1 ]]; then
php_ini_file="/etc/php/7.0/cli/php.ini"
else
php_ini_file="/etc/php/5.6/cli/php.ini"
fi
php_ini_file="/etc/php/${php_version}/cli/php.ini"
pattern=";sendmail_path"
php_config_content="$(cat ${php_ini_file})"
if [[ ${php_config_content} =~ ${pattern} ]]; then
Expand Down

0 comments on commit ffd8967

Please sign in to comment.