Skip to content
This repository was archived by the owner on Oct 1, 2020. It is now read-only.

Commit 3133c57

Browse files
committed
Merge pull request #33 from arkadiych/2.0
Upgrade PHP 5.5.9 to PHP 5.6; Switching PHP versions is applicable after "vagrant reload"
2 parents 63770da + 4e5628c commit 3133c57

File tree

5 files changed

+57
-29
lines changed

5 files changed

+57
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1313

1414
- Removed requirement for public github token due to Composer limitations (issue is fixed on Composer side)
1515
- Changed requirement for minimum box version from 1.0 to 1.1
16+
- Upgraded PHP 5.5.9 to PHP 5.6
1617

1718
### Fixed
1819

@@ -25,6 +26,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
2526
- Added host wrapper script for bin/magento command on guest
2627
- Added ability to modify guest config files (PHP, Apache etc) directly from host IDE
2728
- Added ability to choose if PhpStorm configs should be removed during project reinitialization
29+
- Added ability to switch PHP version without destroying the project ("vagrant reload" is required)
2830

2931
## [v2.0.0] - 2016-02-05
3032

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ bash m-switch-to-ee
167167
```
168168
:information_source: On Windows hosts (or when NFS mode is disabled in [config.yaml](etc/config.yaml.dist) explicitly) you will be asked to wait until code is uploaded to guest machine by PhpStorm (PhpStorm must be lunched). To continue the process press any key.
169169

170+
### Switch between PHP 5.6 and 7
171+
172+
Set "use_php7: 1" for PHP7 and "use_php7: 0" for PHP5.6 in [config.yaml](etc/config.yaml.dist).
173+
PHP version will be applied after "vagrant reload".
174+
170175
### Update Composer dependencies
171176

172177
Go to 'vagrant-magento' created earlier and run in command line:

etc/config.yaml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ guest:
99
ip_address: "192.168.10.2"
1010
forwarded_ssh_port: 3000
1111
environment:
12-
# If set to 0, PHP 5 will be installed
12+
# If set to 0, PHP 5 will be installed. [Changeable: vagrant reload]
1313
use_php7: 1
1414
composer_prefer_source: 0
1515
magento:

scripts/provision/configure_environment.sh

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,33 +29,6 @@ a2ensite magento2.conf
2929
# Disable default virtual host
3030
sudo a2dissite 000-default
3131

32-
# Setup PHP
33-
if [ ${use_php7} -eq 1 ]; then
34-
sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" /etc/php/7.0/cli/php.ini
35-
sed -i "s|display_errors = Off|display_errors = On|g" /etc/php/7.0/cli/php.ini
36-
sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" /etc/php/7.0/cli/php.ini
37-
sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" /etc/php/7.0/cli/php.ini
38-
else
39-
# Uninstall PHP 7 pre-installed in the box
40-
apt-get remove -y php*
41-
42-
# Install PHP 5
43-
apt-get install -y php5 php5-mhash php5-mcrypt php5-curl php5-cli php5-mysql php5-gd php5-intl php5-xsl php5-xdebug curl
44-
if [ ! -f /etc/php5/apache2/conf.d/20-mcrypt.ini ]; then
45-
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/apache2/conf.d/20-mcrypt.ini
46-
fi
47-
if [ ! -f /etc/php5/cli/conf.d/20-mcrypt.ini ]; then
48-
ln -s /etc/php5/mods-available/mcrypt.ini /etc/php5/cli/conf.d/20-mcrypt.ini
49-
fi
50-
echo "date.timezone = America/Chicago" >> /etc/php5/cli/php.ini
51-
52-
# Configure XDebug to allow remote connections from the host
53-
echo 'xdebug.max_nesting_level=200
54-
xdebug.remote_enable=1
55-
xdebug.remote_connect_back=1' >> /etc/php5/cli/conf.d/20-xdebug.ini
56-
fi
57-
service apache2 restart
58-
5932
# Configure composer
6033
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
6134
if [ -f ${composer_auth_json} ]; then

scripts/provision/configure_environment_recurring.sh

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
11
#!/usr/bin/env bash
22

3+
function process_php_config () {
4+
php_ini_paths=$1
5+
6+
for php_ini_path in "${php_ini_paths[@]}"
7+
do
8+
if [ -f ${php_ini_path} ]; then
9+
echo "date.timezone = America/Chicago" >> ${php_ini_path}
10+
sed -i "s|;include_path = \".:/usr/share/php\"|include_path = \".:/usr/share/php:${guest_magento_dir}/vendor/phpunit/phpunit\"|g" ${php_ini_path}
11+
sed -i "s|display_errors = Off|display_errors = On|g" ${php_ini_path}
12+
sed -i "s|display_startup_errors = Off|display_startup_errors = On|g" ${php_ini_path}
13+
sed -i "s|error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT|error_reporting = E_ALL|g" ${php_ini_path}
14+
fi
15+
done
16+
}
17+
18+
function init_php56 () {
19+
sudo add-apt-repository ppa:ondrej/php
20+
sudo apt-get update
21+
sudo 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
22+
echo '
23+
xdebug.max_nesting_level=200
24+
xdebug.remote_enable=1
25+
xdebug.remote_connect_back=1' >> /etc/php/5.6/mods-available/xdebug.ini
26+
}
27+
328
# Enable trace printing and exit on the first error
429
set +x
530

31+
use_php7=$4
32+
633
vagrant_dir="/vagrant"
734

835
# Remove configs from host in case of force stop of virtual machine before linking restored ones
@@ -25,4 +52,25 @@ fi
2552
# Upgrade existing environment
2653
if [ -f ${vagrant_dir}/.idea/deployment.xml ]; then
2754
sed -i.back "s|magento2ce/var/generation|magento2ce/var|g" "${vagrant_dir}/.idea/deployment.xml"
28-
fi
55+
fi
56+
57+
# Setup PHP
58+
php_ini_paths=( /etc/php/7.0/cli/php.ini /etc/php/5.6/cli/php.ini )
59+
process_php_config ${php_ini_paths}
60+
61+
if [ ${use_php7} -eq 1 ]; then
62+
update-alternatives --set php /usr/bin/php7.0
63+
if [ -d "/etc/php/5.6" ]; then
64+
a2dismod php5.6
65+
fi
66+
a2enmod php7.0
67+
else
68+
if [ ! -d "/etc/php/5.6" ]; then
69+
init_php56
70+
fi
71+
update-alternatives --set php /usr/bin/php5.6 && a2dismod php7.0 && a2enmod php5.6
72+
rm -f /etc/php/5.6/apache2/php.ini
73+
ln -s /etc/php/5.6/cli/php.ini /etc/php/5.6/apache2/php.ini
74+
fi
75+
service apache2 restart
76+
#end Setup PHP

0 commit comments

Comments
 (0)