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

Commit 4aeea29

Browse files
committed
Eliminated explicit dependency on PHP for Windows hosts
1 parent a228e25 commit 4aeea29

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
4141
- [Vagrant 1.8+](https://www.vagrantup.com/downloads.html)
4242
- [VirtualBox](https://www.virtualbox.org/wiki/Downloads)
4343
- [PHP](http://php.net/manual/en/install.php) (any version) to allow Magento dependency management with [Composer](https://getcomposer.org/doc/00-intro.md)
44-
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Make sure you have SSH keys generated and associated with your github account, see [manual](https://help.github.com/articles/generating-ssh-keys/).
45-
46-
: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`.
47-
48-
:information_source: On Windows hosts make sure to set the following options to avoid issues with incorrect line separators:
44+
- [Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). Make sure you have SSH keys generated and associated with your github account, see [manual](https://help.github.com/articles/generating-ssh-keys/).<br />
45+
: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 />
46+
:information_source: On Windows hosts make sure to set the following options to avoid issues with incorrect line separators:
4947

5048
```
5149
git config --global core.autocrlf false
@@ -76,7 +74,6 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
7674
```
7775

7876
:information_source: On OSX and \*nix hosts NFS will be used by default to sync your project files with guest. On some hosts Vagrant cannot configure NFS properly, in this case it is possible to deploy project without NFS by setting `use_nfs` option in [config.yaml](etc/config.yaml.dist) to `0`
79-
8077
:information_source: On Windows hosts you might face `Composer Install Error: ZipArchive::extractTo(): Full extraction path exceed MAXPATHLEN (260)` exception during `composer install`. This can be fixed in 2 ways: decrease path length to the project directory or set `composer_prefer_source` option in [config.yaml](etc/config.yaml.dist) to `1`
8178

8279
1. Use `vagrant-magento` directory as project root in PHP Storm (not `vagrant-magento/magento2ce`). This is important, because in this case PHP Storm will be configured automatically by [init_project.sh](init_project.sh). If NFS files sync is disabled in [config](etc/config.yaml.dist) and on Windows hosts [verify deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md)

docs/images/release_badge.svg

Lines changed: 1 addition & 0 deletions
Loading

lib/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*

scripts/host/check_requirements.sh

100644100755
Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
77
set -ex
88

99
if ! php -v | grep -q 'Copyright' ; then
10-
set +x
11-
echo "Please install PHP (any version) to allow Magento dependencies management using Composer."
12-
exit 255
13-
set -x
10+
bash "${vagrant_dir}/scripts/host/install_php.sh"
1411
fi
1512

1613
if [ ! -f ${composer_auth_json} ]; then

scripts/host/composer.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ 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+
1623
# Setup composer if necessary
1724
if [ ! -f ${composer_phar} ]; then
1825
cd ${composer_dir}
@@ -26,8 +33,8 @@ cp ${composer_auth_json} "${PWD}/auth.json"
2633
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
2734
if [[ $(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "environment_composer_prefer_source") == 1 ]]; then
2835
# prefer-source is slow but guarantees that there will be no issues related to max path length on Windows
29-
php ${composer_phar} --ignore-platform-reqs --prefer-source "$@"
36+
${php_executable} ${composer_phar} --ignore-platform-reqs --prefer-source "$@"
3037
else
31-
php ${composer_phar} --ignore-platform-reqs "$@"
38+
${php_executable} ${composer_phar} --ignore-platform-reqs "$@"
3239
fi
3340
rm "${PWD}/auth.json"

scripts/host/configure_php_storm.sh

100644100755
File mode changed.

scripts/host/install_php.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
4+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
5+
6+
# Enable trace printing and exit on the first error
7+
set -ex
8+
9+
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
11+
unzip -q ${vagrant_dir}/lib/php.zip -d ${vagrant_dir}/lib/php
12+
rm -f ${vagrant_dir}/lib/php.zip
13+
fi
14+
15+
if ! php -v | grep -q 'Copyright' ; then
16+
set +x
17+
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"
18+
exit 255
19+
set -x
20+
else
21+
set +x
22+
echo "PHP installed successfully."
23+
set -x
24+
fi

0 commit comments

Comments
 (0)