Skip to content

Commit 4d8b18a

Browse files
author
Alexander Paliarush
committed
- Guest configs editable from IDE (#29)
- Added ability to choose if PhpStorm configs should be removed during project reinitialization
1 parent 7446aee commit 4d8b18a

File tree

5 files changed

+37
-25
lines changed

5 files changed

+37
-25
lines changed

CHANGELOG.md

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

2424
- Added host wrapper script for bin/magento command on guest
2525
- Added ability to modify guest config files (PHP, Apache etc) directly from host IDE
26+
- Added ability to choose if PhpStorm configs should be removed during project reinitialization
2627

2728
## [v2.0.0] - 2016-02-05
2829

@@ -52,18 +53,18 @@ This project adheres to [Semantic Versioning](http://semver.org/).
5253

5354
### Added
5455

55-
- Integrated vagrant host manager plugin to allow automatic /etc/hosts update
56-
- Added support of EE linked to CE using symlinks on *nix hosts
56+
- Integrated vagrant host manager plugin to allow automatic /etc/hosts update
57+
- Added support of EE linked to CE using symlinks on *nix hosts
5758
- Added ${MAGENTO_ROOT} environment variable, which stores installation path on the guest
5859
- Added support of Rabbit MQ
59-
- Added possibility to specify tokens for repo.magento.com composer repository
60+
- Added possibility to specify tokens for repo.magento.com composer repository
6061
- git is now installed on guest machine
61-
- Removed 'magento' MySQL user, password of 'root' user removed
62-
- Database for integration tests are created by default
63-
- Added script for clearing Magento cache from host command line
62+
- Removed 'magento' MySQL user, password of 'root' user removed
63+
- Database for integration tests are created by default
64+
- Added script for clearing Magento cache from host command line
6465
- Configured XDebug to allow remote debugging
65-
- Fixed max_nesting_level issue with XDebug enabled
66+
- Fixed max_nesting_level issue with XDebug enabled
6667
- Apache is run by 'vagrant' user
67-
- Enabled Magento cron jobs
68+
- Enabled Magento cron jobs
6869
- Enabled XDebug by default
6970
- Created vagrant configuration for Magneto 2 CE developer's environment installation

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Answer can be found [here](https://github.com/paliarush/magento2-vagrant-for-dev
213213

214214
### Accessing PHP and other config files
215215

216-
It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes, but not limited to: PHP, Apache, Mysql, Varnish, RabbitMQ, hosts, cron.
216+
It is possible to view/modify majority of guest machine config files directly from IDE on the host. They will be accessible in [etc/guest](etc/guest) directory only when guest machine is running. The list of accessible configs includes: PHP, Apache, Mysql, Varnish, RabbitMQ.
217217
Do not edit any symlinks using PhpStorm because it may break your installation.
218218

219219
After editing configs in IDE it is still required to restart related services manually.
@@ -240,3 +240,11 @@ Go to 'vagrant-magento' created earlier and run in command line:
240240
```
241241
bash init_project.sh -fc
242242
```
243+
244+
To reset PhpStorm project configuration, in addition to `-f` specify `-p` option:
245+
246+
```
247+
bash init_project.sh -fp
248+
OR
249+
bash init_project.sh -fcp
250+
```

init_project.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ rm -f "${config_path}.back"
3737
# Clean up the project before initialization if "-f" option was specified. Remove codebase if "-fc" is used.
3838
force_project_cleaning=0
3939
force_codebase_cleaning=0
40-
while getopts 'fc' flag; do
40+
force_phpstorm_config_cleaning=0
41+
while getopts 'fcp' flag; do
4142
case "${flag}" in
4243
f) force_project_cleaning=1 ;;
4344
c) force_codebase_cleaning=1 ;;
45+
p) force_phpstorm_config_cleaning=1 ;;
4446
*) error "Unexpected option ${flag}" ;;
4547
esac
4648
done
@@ -82,10 +84,12 @@ vagrant up
8284

8385
set +x
8486
echo "Configuring PhpStorm..."
85-
if [ ${force_project_cleaning} -eq 1 ]; then
86-
rm -rf ${vagrant_dir}/.idea/*
87+
if [ ${force_project_cleaning} -eq 1 ] && [ ${force_phpstorm_config_cleaning} -eq 1 ]; then
88+
rm -rf ${vagrant_dir}/.idea
89+
fi
90+
if [ ! "$(ls -A ${vagrant_dir}/.idea)" ]; then
91+
bash "${vagrant_dir}/scripts/host/configure_php_storm.sh"
8792
fi
88-
bash "${vagrant_dir}/scripts/host/configure_php_storm.sh"
8993

9094
bold=$(tput bold)
9195
regular=$(tput sgr0)

scripts/guest/link_configs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,19 @@ function process_configs () {
1919
# Enable trace printing and exit on the first error
2020
set -ex
2121

22+
# Below configuration is required to allow managing mysql as a service
23+
if ! cat /etc/apparmor.d/local/usr.sbin.mysqld | grep -q '/vagrant/etc/guest' ; then
24+
echo "
25+
/vagrant/etc/guest/mysql/*.pem r,
26+
/vagrant/etc/guest/mysql/conf.d/ r,
27+
/vagrant/etc/guest/mysql/conf.d/* r,
28+
/vagrant/etc/guest/mysql/*.cnf r," >> /etc/apparmor.d/local/usr.sbin.mysqld
29+
fi
30+
2231
# Make guest configs visible and editable in the host IDE
2332

2433
# Configs located under /etc/*
2534
config_dir="/etc"
2635
# See unlink_configs script
27-
configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d )
36+
configs=( apache2 php mysql varnish rabbitmq )
2837
process_configs ${config_dir} ${configs}
29-
30-
# Configs located under ~/*
31-
config_dir="/home/vagrant"
32-
configs=( .bashrc .composer .profile )
33-
process_configs ${config_dir} ${configs}

scripts/guest/unlink_configs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,5 @@ set -ex
2323
# Configs located under /etc/*
2424
config_dir="/etc"
2525
# See link_configs script
26-
configs=( apache2 php mysql varnish rabbitmq crontab cron.d timezone hosts profile profile.d )
27-
process_configs ${config_dir} ${configs}
28-
29-
# Configs located under ~/*
30-
config_dir="/home/vagrant"
31-
configs=( .bashrc .composer .profile )
26+
configs=( apache2 php mysql varnish rabbitmq )
3227
process_configs ${config_dir} ${configs}

0 commit comments

Comments
 (0)