Skip to content

Commit 6ddf0bf

Browse files
committed
Eliminated explicit dependency on PHP for Windows hosts
1 parent 84c7527 commit 6ddf0bf

File tree

5 files changed

+25
-11
lines changed

5 files changed

+25
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
4040

4141
- [Vagrant 1.8+](https://www.vagrantup.com/downloads.html)
4242
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
43-
- [PHP](http://php.net/manual/en/install.php) (any version) to allow Magento dependency management with [Composer](https://getcomposer.org/doc/00-intro.md)
4443
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git), on Windows must be [v2.7+](http://git-scm.com/download/win). Make sure you have SSH keys generated and associated with your github account, see [manual](https://help.github.com/articles/generating-ssh-keys/).<br />
4544
:information_source: It is possible to use another way of getting codebase instead of cloning, it does not matter for successful installation. Just put Magento 2 codebase inside of `vagrant-magento/magento2ce`.<br />
4645
:information_source: On Windows hosts make sure to set the following options to avoid issues with incorrect line separators:
@@ -50,6 +49,7 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
5049
git config --global core.eol LF
5150
git config --global diff.renamelimit 5000
5251
```
52+
- [PHP](http://php.net/manual/en/install.php) (any version, will be installed automatically on Windows if missing) to allow Magento dependency management with [Composer](https://getcomposer.org/doc/00-intro.md)
5353
- [PHP Storm](https://www.jetbrains.com/phpstorm) is optional but recommended.
5454

5555
### Installation steps

scripts/host/check_requirements.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
44
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
5+
php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
56

67
# Enable trace printing and exit on the first error
78
set -ex
89

9-
if ! php -v | grep -q 'Copyright' ; then
10+
if ! ${php_executable} -v | grep -q 'Copyright' ; then
1011
bash "${vagrant_dir}/scripts/host/install_php.sh"
1112
fi
1213

scripts/host/composer.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ set -ex
1313

1414
bash "${vagrant_dir}/scripts/host/check_requirements.sh"
1515

16-
# Find path to available PHP
17-
if php -v | grep -q 'Copyright' ; then
18-
php_executable="php"
19-
else
20-
php_executable="${vagrant_dir}/lib/php/php"
21-
fi
22-
2316
# Setup composer if necessary
2417
if [ ! -f ${composer_phar} ]; then
2518
cd ${composer_dir}
@@ -30,6 +23,7 @@ fi
3023
cd ${current_dir}
3124
cp ${composer_auth_json} "${PWD}/auth.json"
3225

26+
php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
3327
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
3428
if [[ $(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "environment_composer_prefer_source") == 1 ]]; then
3529
# prefer-source is slow but guarantees that there will be no issues related to max path length on Windows

scripts/host/get_path_to_php.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
4+
5+
# Enable trace printing and exit on the first error
6+
set -ex
7+
8+
# Find path to available PHP
9+
if [ -f ${vagrant_dir}/lib/php/php.exe ]; then
10+
php_executable="${vagrant_dir}/lib/php/php"
11+
else
12+
php_executable="php"
13+
fi
14+
echo ${php_executable}

scripts/host/install_php.sh

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
77
set -ex
88

99
if [[ ${host_os} == "Windows" ]]; then
10-
wget http://windows.php.net/downloads/releases/php-7.0.2-nts-Win32-VC14-x86.zip -O ${vagrant_dir}/lib/php.zip
10+
curl http://windows.php.net/downloads/releases/php-7.0.2-nts-Win32-VC14-x86.zip -o ${vagrant_dir}/lib/php.zip
1111
unzip -q ${vagrant_dir}/lib/php.zip -d ${vagrant_dir}/lib/php
1212
rm -f ${vagrant_dir}/lib/php.zip
13+
cp "${vagrant_dir}/lib/php/php.ini-development" "${vagrant_dir}/lib/php/php.ini"
14+
sed -i.back 's|; extension_dir = "ext"|extension_dir = "ext"|g' "${vagrant_dir}/lib/php/php.ini"
15+
sed -i.back 's|;extension=php_openssl.dll|extension=php_openssl.dll|g' "${vagrant_dir}/lib/php/php.ini"
16+
rm -rf ${vagrant_dir}/lib/php/*.back
1317
fi
1418

15-
if ! php -v | grep -q 'Copyright' ; then
19+
php_executable=$(bash "${vagrant_dir}/scripts/host/get_path_to_php.sh")
20+
if ! ${php_executable} -v | grep -q 'Copyright' ; then
1621
set +x
1722
echo "Automatic PHP installation is not available for your host OS. Please install any version of PHP to allow Magento dependencies management using Composer. Check out http://php.net/manual/en/install.php"
1823
exit 255

0 commit comments

Comments
 (0)