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

Commit 8a46585

Browse files
committed
Refactoring
- Renamed local.config => etc - Moved scripts from scripts/host/shell to script/host - Improved composer update and git experience for Windows hosts - Removed "latest release" badge (it is not stable)
1 parent 4288bc9 commit 8a46585

14 files changed

+60
-44
lines changed

CHANGELOG.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1212

1313
- Moved provisioning scripts
1414
- Magento project directory moved to vagrant project root. Current structure is as follows: `vagrant-magento/magento2ce/magento2ee`
15-
- PHP 7.0 is installed by default instead of PHP 5.5.9 (can be configured in [local.config/config.yaml.dist](local.config/config.yaml.dist))
15+
- PHP 7.0 is installed by default instead of PHP 5.5.9 (can be configured in [etc/config.yaml.dist](etc/config.yaml.dist))
16+
- Renamed configuration folder from `local.config` to `etc`
17+
- Set minimum Vagrant version as 1.8
1618

1719
### Added
1820

1921
- Implemented static value of forwarded SSH port to prevent necessity to reconfigure software accessing guest via SSH
2022
- Implemented collision prevention for IP address and host name (in case when several machines are created at once)
21-
- Added configuration file [local.config/config.yaml.dist](local.config/config.yaml.dist)
23+
- Added configuration file [etc/config.yaml.dist](etc/config.yaml.dist)
2224
- Added PHP 7.0 support
2325
- Added PHP Storm configuration during project initialization
2426
- Added [project initialization script](init_project.sh) for *nix and OSX hosts

README.md

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Vagrant project for Magento 2 developers (optimized for Mac, Windows and \*nix hosts)
22

3-
[![Latest GitHub release](https://img.shields.io/github/release/paliarush/magento2-vagrant-for-developers.svg)](https://github.com/paliarush/magento2-vagrant-for-developers/releases/latest)
3+
# [![Latest GitHub release](https://img.shields.io/github/release/paliarush/magento2-vagrant-for-developers.svg)](https://github.com/paliarush/magento2-vagrant-for-developers/releases/latest)
44
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
55
[![Semver](http://img.shields.io/SemVer/2.0.0.png?color=blue)](http://semver.org/spec/v2.0.0.html)
66

@@ -41,8 +41,15 @@ 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-
:information_source: It is possible to use another way of getting codebase instead of cloning, it does not matter for successful installation.
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:
47+
48+
```
49+
git config --global core.autocrlf false
50+
git config --global core.eol LF
51+
git config --global diff.renamelimit 5000
52+
```
4653
- [PHP Storm](https://www.jetbrains.com/phpstorm) is optional but recommended.
4754

4855
### Installation steps
@@ -55,9 +62,9 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
5562
git clone git@github.com:paliarush/magento2-vagrant-for-developers.git vagrant-magento
5663
```
5764

58-
1. Copy [local.config/composer/auth.json.dist](local.config/composer/auth.json.dist) to `local.config/composer/auth.json` and specify your [GitHub OAuth token](https://github.com/settings/tokens) there. See [API rate limit and OAuth tokens](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens) for more information
65+
1. Copy [etc/composer/auth.json.dist](etc/composer/auth.json.dist) to `etc/composer/auth.json` and specify your [GitHub OAuth token](https://github.com/settings/tokens) there. See [API rate limit and OAuth tokens](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens) for more information
5966

60-
1. Optionally, copy [local.config/config.yaml.dist](local.config/config.yaml.dist) as `local.config/config.yaml` and make necessary customizations
67+
1. Optionally, copy [etc/config.yaml.dist](etc/config.yaml.dist) as `etc/config.yaml` and make necessary customizations
6168

6269
1. Initialize project, configure environment, install Magento, configure PHPStorm project:
6370

@@ -66,12 +73,13 @@ Software listed below should be available in [PATH](https://en.wikipedia.org/wik
6673
bash init_project.sh
6774
```
6875

69-
: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](local.config/config.yaml.dist) to `0`
76+
: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`
77+
: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`
7078

71-
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](local.config/config.yaml.dist) and on Windows hosts [verify deployment configuration in PHP Storm](docs/phpstorm-configuration-windows-hosts.md)
79+
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)
7280

7381
### Default credentials and settings
74-
Some of default settings are available for override. These settings can be found in the file [local.config/config.yaml.dist](local.config/config.yaml.dist).
82+
Some of default settings are available for override. These settings can be found in the file [etc/config.yaml.dist](etc/config.yaml.dist).
7583
To override settings just create a copy of the file under the name 'config.yaml' and put there your custom settings.
7684
When using [init_project.sh](init_project.sh), if not specified manually, random IP address is generated and is used as suffix for host name to prevent collisions, in case when 2 or more instances are running at the same time.
7785
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application in console.
@@ -99,7 +107,7 @@ These limits may significantly slow down the installation since all of the libra
99107

100108
If you have a GitHub account, you can bypass these limitations by using an OAuth token in the Composer configuration. See [API rate limit and OAuth tokens](https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens) for more information.
101109

102-
For the Vagrant configuration you may specify your token in `local.config/github.oauth.token` file after cloning the repository. The file is a basic text file and is ignored by Git, so you'll need to create it yourself. Simply write your OAuth token in this file making sure to avoid any empty spaces, and it will be read during deployment.
110+
For the Vagrant configuration you may specify your token in `etc/github.oauth.token` file after cloning the repository. The file is a basic text file and is ignored by Git, so you'll need to create it yourself. Simply write your OAuth token in this file making sure to avoid any empty spaces, and it will be read during deployment.
103111

104112
## Day-to-day development scenarios
105113

Vagrantfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ end
1414
module Config
1515
# Load and override config settings
1616
def Config.load
17-
local_config_dir = 'local.config'
17+
local_config_dir = 'etc'
1818
config_dist_file = local_config_dir + '/config.yaml.dist'
1919
config_file = local_config_dir + '/config.yaml'
2020

@@ -46,7 +46,7 @@ Vagrant.configure(VAGRANT_API_VERSION) do |config|
4646
end
4747

4848
config.vm.synced_folder '.', '/vagrant', disabled: true
49-
config.vm.synced_folder './local.config', '/vagrant/local.config'
49+
config.vm.synced_folder './etc', '/vagrant/etc'
5050
config.vm.synced_folder './scripts', '/vagrant/scripts'
5151
if use_nfs_for_synced_folders
5252
guest_magento_dir = host_magento_dir
File renamed without changes.
File renamed without changes.

local.config/config.yaml.dist etc/config.yaml.dist

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ guest:
1111
environment:
1212
# If set to 0, PHP 5 will be installed
1313
use_php7: 1
14+
composer_prefer_source: 0
1415
magento:
1516
host_name: "magento2.vagrant2"
1617
admin_frontname: "admin"

init_project.sh

+14-9
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
vagrant_dir=$PWD
44
magento_ce_dir="${vagrant_dir}/magento2ce"
55
magento_ee_dir="${magento_ce_dir}/magento2ee"
6-
config_path="${vagrant_dir}/local.config/config.yaml"
6+
config_path="${vagrant_dir}/etc/config.yaml"
7+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
78

89
# Enable trace printing and exit on the first error
910
set -ex
1011

11-
bash "${vagrant_dir}/scripts/host/shell/check_requirements.sh"
12+
bash "${vagrant_dir}/scripts/host/check_requirements.sh"
1213

1314
# Generate random IP address and host name to prevent collisions, if not specified explicitly in local config
14-
if [ ! -f "${vagrant_dir}/local.config/config.yaml" ]; then
15+
if [ ! -f "${vagrant_dir}/etc/config.yaml" ]; then
1516
cp "${config_path}.dist" ${config_path}
1617
fi
1718
random_ip=$(( ( RANDOM % 240 ) + 12 ))
@@ -35,28 +36,32 @@ if [ ${force_project_cleaning} -eq 1 ]; then
3536
fi
3637

3738
if [ ! -d ${magento_ce_dir} ]; then
39+
if [[ ${host_os} == "Windows" ]]; then
40+
git config --global core.autocrlf false
41+
git config --global core.eol LF
42+
git config --global diff.renamelimit 5000
43+
fi
3844
# Check out CE repository
39-
repository_url_ce=$(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "repository_url_ce")
45+
repository_url_ce=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "repository_url_ce")
4046
git clone ${repository_url_ce} ${magento_ce_dir}
4147
# Check out EE repository
4248
# By default EE repository is not specified and EE project is not checked out
43-
repository_url_ee=$(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "repository_url_ee")
49+
repository_url_ee=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "repository_url_ee")
4450
if [ -n "${repository_url_ee}" ]; then
4551
git clone ${repository_url_ee} ${magento_ee_dir}
4652
fi
4753
fi
4854

4955
var_generation_dir="${magento_ce_dir}/var/generation"
5056
if [ ! -d ${var_generation_dir} ] ; then
51-
host_os=$(bash "${vagrant_dir}/scripts/host/shell/get_host_os.sh")
52-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "guest_use_nfs") == 0 ]]; then
57+
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "guest_use_nfs") == 0 ]]; then
5358
mkdir ${var_generation_dir}
5459
fi
5560
fi
5661

5762
# Update Magento dependencies via Composer
5863
cd ${magento_ce_dir}
59-
bash "${vagrant_dir}/scripts/host/shell/composer.sh" install
64+
bash "${vagrant_dir}/scripts/host/composer.sh" install
6065

6166
# Install necessary vagrant plugins if not installed
6267
if ! vagrant plugin list | grep -q 'vagrant-hostmanager' ; then
@@ -73,4 +78,4 @@ fi
7378
cd ${vagrant_dir}
7479
vagrant up
7580

76-
bash "${vagrant_dir}/scripts/host/shell/configure_php_storm.sh"
81+
bash "${vagrant_dir}/scripts/host/configure_php_storm.sh"

scripts/host/shell/check_requirements.sh scripts/host/check_requirements.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

3-
vagrant_dir=$(cd "$(dirname "$0")/../../.."; pwd)
4-
composer_auth_json="${vagrant_dir}/local.config/composer/auth.json"
3+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
4+
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
55

66
# Enable trace printing and exit on the first error
77
set -ex

scripts/host/shell/composer.sh scripts/host/composer.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
#!/usr/bin/env bash
22

3-
# This script allows to use credentials specified in local.config/composer/auth.json without declaring them globally
3+
# This script allows to use credentials specified in etc/composer/auth.json without declaring them globally
44

55
current_dir=${PWD}
6-
vagrant_dir=$(cd "$(dirname "$0")/../../.."; pwd)
7-
composer_auth_json="${vagrant_dir}/local.config/composer/auth.json"
6+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
7+
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
88
composer_dir="${vagrant_dir}/scripts/host"
99
composer_phar="${composer_dir}/composer.phar"
1010

1111
# Enable trace printing and exit on the first error
1212
set -ex
1313

14-
bash "${vagrant_dir}/scripts/host/shell/check_requirements.sh"
14+
bash "${vagrant_dir}/scripts/host/check_requirements.sh"
1515

1616
# Setup composer if necessary
1717
if [ ! -f ${composer_phar} ]; then
@@ -23,9 +23,9 @@ fi
2323
cd ${current_dir}
2424
cp ${composer_auth_json} "${PWD}/auth.json"
2525

26-
host_os=$(bash "${vagrant_dir}/scripts/host/shell/get_host_os.sh")
27-
if [[ ${host_os} == "Windows" ]]; then
28-
# prefer-source option guarantees that there will be no issues related to max path length on Windows
26+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
27+
if [[ $(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "environment_composer_prefer_source") == 1 ]]; then
28+
# prefer-source is slow but guarantees that there will be no issues related to max path length on Windows
2929
php ${composer_phar} --ignore-platform-reqs --prefer-source "$@"
3030
else
3131
php ${composer_phar} --ignore-platform-reqs "$@"

scripts/host/shell/configure_php_storm.sh scripts/host/configure_php_storm.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
#!/usr/bin/env bash
22

3-
vagrant_dir=$(cd "$(dirname "$0")/../../.."; pwd)
4-
composer_auth_json="${vagrant_dir}/local.config/composer/auth.json"
3+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
4+
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
55

66
# Enable trace printing and exit on the first error
77
set +x
88

99
cd ${vagrant_dir}
10-
ssh_port=$(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "guest_forwarded_ssh_port")
11-
magento_host_name=$(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "magento_host_name")
10+
ssh_port=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "guest_forwarded_ssh_port")
11+
magento_host_name=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "magento_host_name")
1212

1313
cp -R "${vagrant_dir}/scripts/host/php-storm-configs/." "${vagrant_dir}/.idea/"
1414

1515
enabled_virtual_host_config="/etc/apache2/sites-available/magento2.conf"
1616

17-
host_os=$(bash "${vagrant_dir}/scripts/host/shell/get_host_os.sh")
18-
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "guest_use_nfs") == 0 ]]; then
17+
host_os=$(bash "${vagrant_dir}/scripts/host/get_host_os.sh")
18+
if [[ ${host_os} == "Windows" || $(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "guest_use_nfs") == 0 ]]; then
1919
sed -i.back "s|<magento_guest_path>|/var/www/magento2ce|g" "${vagrant_dir}/.idea/deployment.xml"
2020
sed -i.back 's|<auto_upload_attributes>| autoUpload="Always" autoUploadExternalChanges="true"|g' "${vagrant_dir}/.idea/deployment.xml"
2121
sed -i.back 's|<auto_upload_option>|<option name="myAutoUpload" value="ALWAYS" />|g' "${vagrant_dir}/.idea/deployment.xml"
@@ -38,7 +38,7 @@ rm -f ${vagrant_dir}/.idea/.name.back
3838

3939
mv "${vagrant_dir}/.idea/host_name.iml" "${vagrant_dir}/.idea/${magento_host_name}.iml"
4040

41-
repository_url_ee=$(bash "${vagrant_dir}/scripts/host/shell/get_variable_value.sh" "repository_url_ee")
41+
repository_url_ee=$(bash "${vagrant_dir}/scripts/host/get_variable_value.sh" "repository_url_ee")
4242
if [ -z ${repository_url_ee} ]; then
4343
mv "${vagrant_dir}/.idea/vcs.ce.xml" "${vagrant_dir}/.idea/vcs.xml"
4444
rm "${vagrant_dir}/.idea/vcs.ee.xml"
File renamed without changes.

scripts/host/shell/get_variable_value.sh scripts/host/get_variable_value.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ parse_yaml() {
1717
}'
1818
}
1919

20-
vagrant_dir=$(cd "$(dirname "$0")/../../.."; pwd)
20+
vagrant_dir=$(cd "$(dirname "$0")/../.."; pwd)
2121
variable_name=$1
2222

2323
# Read configs
24-
eval $(parse_yaml "${vagrant_dir}/local.config/config.yaml.dist")
25-
eval $(parse_yaml "${vagrant_dir}/local.config/config.yaml")
24+
eval $(parse_yaml "${vagrant_dir}/etc/config.yaml.dist")
25+
eval $(parse_yaml "${vagrant_dir}/etc/config.yaml")
2626

2727
echo ${!variable_name}

scripts/provision/configure_environment.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use_php7=$4
1111
vagrant_dir="/vagrant"
1212

1313
# Enable Magento virtual host
14-
custom_virtual_host_config="${vagrant_dir}/local.config/magento2_virtual_host.conf"
15-
default_virtual_host_config="${vagrant_dir}/local.config/magento2_virtual_host.conf.dist"
14+
custom_virtual_host_config="${vagrant_dir}/etc/magento2_virtual_host.conf"
15+
default_virtual_host_config="${vagrant_dir}/etc/magento2_virtual_host.conf.dist"
1616
if [ -f ${custom_virtual_host_config} ]; then
1717
virtual_host_config=${custom_virtual_host_config}
1818
else
@@ -52,7 +52,7 @@ fi
5252
service apache2 restart
5353

5454
# Configure composer
55-
composer_auth_json="${vagrant_dir}/local.config/composer/auth.json"
55+
composer_auth_json="${vagrant_dir}/etc/composer/auth.json"
5656
if [ -f ${composer_auth_json} ]; then
5757
set +x
5858
echo "Installing composer OAuth tokens from ${composer_auth_json}..."

0 commit comments

Comments
 (0)