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

Commit faa24c2

Browse files
author
Alexander Paliarush
committed
- Removed 'magento' MySQL user, password of 'root' user removed
- Database for integration tests are created by default - Added script for clearing Magento cache from host command line. Added related documentation - Configured XDebug to allow remote debugging. Added related documentation
1 parent ab6600f commit faa24c2

7 files changed

+79
-28
lines changed

Diff for: README.md

+32-14
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ With current configuration Vagrant will:
1212
1. Install all necessary libraries
1313
1. Install the Magento 2 application
1414

15-
## Usage
15+
## Environment set up workflow
1616

1717
If you never used Vagrant before, read [Vagrant Docs](https://docs.vagrantup.com/v2/)
1818

@@ -51,21 +51,11 @@ If you never used Vagrant before, read [Vagrant Docs](https://docs.vagrantup.com
5151
192.168.10.11 magento2.vagrant
5252
```
5353
1. After the installation is complete, [set up synchronization with PHP Storm](docs/phpstorm-configuration.md)
54-
55-
###To reinstall Magento
56-
To save some time and get clear Magento installation, you can skip installation of software like web server or php.
57-
The following command will clear Magento DB, Magento caches and reinstall Magento instance.
58-
59-
Go to 'vagrant-magento' created earlier and run in command line:
60-
61-
```
62-
vagrant provision --provision-with install_magento
63-
```
6454
6555
### After installation
6656
6757
Upon a successful installation, you'll see the location and URL of the newly-installed Magento 2 application in console.
68-
See a list of [default credentials and settings](README.md#default-credentials) below.
58+
See a list of [default credentials and settings](README.md#default-credentials).
6959
7060
### Default credentials and settings
7161
@@ -77,8 +67,8 @@ Web access:
7767
Codebase and DB access:
7868
- Path to your Magento installation on the VM: `/var/www/magento2ce`
7969
- MySQL DB host: `localhost` (not accessible remotely)
80-
- MySQL DB name: `magento`
81-
- MySQL DB user/password: `magento/magento`. Alternatively `root/password`
70+
- MySQL DB name: `magento`, `magento_integration_tests`
71+
- MySQL DB user/password: just use `mysql` with no user and password (`root/password` will be used by default)
8272
8373
### GitHub Limitations
8474
@@ -93,6 +83,34 @@ For the Vagrant configuration you may specify your token in `local.config/github
9383
Installing GitHub OAuth token from /vagrant/local.config/github.oauth.token
9484
```
9585
86+
## Magento development workflow
87+
88+
### Reinstall Magento
89+
To save some time and get clear Magento installation, you can skip installation of software like web server or php.
90+
The following command will clear Magento DB, Magento caches and reinstall Magento instance.
91+
92+
Go to 'vagrant-magento' created earlier and run in command line:
93+
94+
```
95+
vagrant provision --provision-with install_magento
96+
```
97+
98+
### Clear magento cache
99+
100+
Go to 'vagrant-magento' created earlier and run in command line:
101+
102+
```
103+
vagrant ssh -c 'magento_clear_cache'
104+
```
105+
106+
### Debugging with XDebug
107+
108+
XDebug is already configured to connect to the host machine automatically. So just:
109+
110+
1. Set XDEBUG_SESSION=1 cookie (e.g. using 'easy Xdebug' extension for Firefox). See [XDebug documentation](http://xdebug.org/docs/remote) for more details
111+
1. Start listening for PHP Debug connections in PhpStorm. See how to [integrate XDebug with PhpStorm](https://www.jetbrains.com/phpstorm/help/configuring-xdebug.html#integrationWithProduct)
112+
1. Set beakpoint or set option in PhpStorm menu 'Run -> Break at first line in PHP scripts'
113+
96114
## Related Repositories
97115
98116
- https://github.com/buskamuza/magento2-product-vagrant

Diff for: bin/magento_clear_cache

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
echo "Clearing Magento cache..."
4+
5+
magento_path=/var/www/magento2ce
6+
7+
rm -f ${magento_path}/app/etc/paths.php
8+
#clear var
9+
for dir in `ls ${magento_path}/var` ; do
10+
rm -rf ${magento_path}/var/${dir}/* ;
11+
done
12+
#clear pub/statics
13+
cd ${magento_path}/pub && mv static/.htaccess static_htaccess.back && rm -rf static/* && mv static_htaccess.back static/.htaccess
14+
#clear integration tests tmp
15+
cd ${magento_path}/dev/tests/integration && mv tmp/.gitignore tmp_gitignore.back && rm -rf tmp/* && mv tmp_gitignore.back tmp/.gitignore
16+
#clear unit tests tmp
17+
cd ${magento_path}/dev/tests/unit && rm -rf tmp/*
18+
19+
echo "Magento cache cleared."

Diff for: docs/developer-use-cases.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Synchronization with local PHP Storm
22
-----------------
33

4-
1. You can upload full Magento code base to the virtual machine from the host machine using context menu on the root of the project in PHPStorm.
4+
1. You can upload full Magento code base to the virtual machine from the host machine using context menu on the root of the project in PhpStorm.
55

66
![](images/upload-magento-codebase.png)

Diff for: docs/performance-issue-on-windows-hosts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ Even though there are no out-of-the-box solution which satisfies our developer e
3131
- does not break developer experience
3232
- has negligible performance degradation caused by files synchronization
3333

34-
To solve performance degradation problem, local copy of the project should be stored on host (for good indexing performance in IDE) and on the guest (to avoid delays caused by PHP requesting remote files via network). This cannot be achieved with built-in Vagrant synchronization capabilities. However, this can be done using one-way PHPStorm project deployment to remote host or by using rsync. This approach has one drawback: all files generated on the guest, will not be visible to IDE and as a result autocomplete for auto-generated classes will be unavailable. This issue can be overcome by enabling two-way Vagrant synchronization for those files which should be downloaded from guest OS.
34+
To solve performance degradation problem, local copy of the project should be stored on host (for good indexing performance in IDE) and on the guest (to avoid delays caused by PHP requesting remote files via network). This cannot be achieved with built-in Vagrant synchronization capabilities. However, this can be done using one-way PhpStorm project deployment to remote host or by using rsync. This approach has one drawback: all files generated on the guest, will not be visible to IDE and as a result autocomplete for auto-generated classes will be unavailable. This issue can be overcome by enabling two-way Vagrant synchronization for those files which should be downloaded from guest OS.

Diff for: docs/phpstorm-configuration.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This solution is applicable to any Vagrant configuration for Magento instance, s
1212
end
1313
```
1414
15-
1. Open your project on host machine in PHPStorm and set up deployment configuration, which will upload to the guest machine everything except for those folders which are synchronized by Vagrant. :information_source: Note that rsync can be used instead of PHP Storm deployment.
15+
1. Open your project on host machine in PhpStorm and set up deployment configuration, which will upload to the guest machine everything except for those folders which are synchronized by Vagrant. :information_source: Note that rsync can be used instead of PHP Storm deployment.
1616
1. Go to Tools -> Deployment -> Configuration
1717
1818
![](images/deployment-configuration.png)
@@ -34,7 +34,7 @@ This solution is applicable to any Vagrant configuration for Magento instance, s
3434
3535
![](images/projects-mapping.png)
3636
37-
1. Add remote paths excluded from synchronization by PHPStorm. You should add those paths which are specified in Vagrant config for synchronization.
37+
1. Add remote paths excluded from synchronization by PhpStorm. You should add those paths which are specified in Vagrant config for synchronization.
3838
3939
![](images/exclude-paths-from-mapping.png)
4040

Diff for: install_environment.sh

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env bash
22

3+
# Enable trace printing and exit on the first error
34
set -ex
45

56
apt-get update
@@ -46,8 +47,10 @@ if [ ! -f /etc/php5/cli/conf.d/20-mcrypt.ini ]; then
4647
fi
4748
echo "date.timezone = America/Chicago" >> /etc/php5/cli/php.ini
4849

49-
# Configure XDebug
50-
echo "xdebug.max_nesting_level=200" >> /etc/php5/cli/conf.d/20-xdebug.ini
50+
# Configure XDebug to allow remote connections from the host
51+
echo "xdebug.max_nesting_level=200\
52+
xdebug.remote_enable=1\
53+
xdebug.remote_connect_back=1" >> /etc/php5/cli/conf.d/20-xdebug.ini
5154

5255
# Restart Apache
5356
service apache2 restart
@@ -56,6 +59,12 @@ service apache2 restart
5659
debconf-set-selections <<< 'mysql-server mysql-server/root_password password password'
5760
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password password'
5861
apt-get install -q -y mysql-server-5.6 mysql-client-5.6
62+
mysqladmin -uroot -ppassword password ''
63+
64+
# Make it possible to run 'mysql' without username and password
65+
sed -i '/\[client\]/a\
66+
user = root\
67+
password =' /etc/mysql/my.cnf
5968

6069
# Setup Composer
6170
if [ ! -f /usr/local/bin/composer ]; then
@@ -66,4 +75,8 @@ fi
6675

6776
# Set permissions to allow Magento codebase upload by Vagrant provision script
6877
chown -R vagrant:vagrant /var/www
69-
chmod -R 755 /var/www
78+
chmod -R 755 /var/www
79+
80+
# Declare path to scripts supplied with vagrant and Magento
81+
magento_dir="/var/www/magento2ce"
82+
echo "export PATH=\$PATH:/vagrant/bin:${magento_dir}/bin" >> /home/vagrant/.profile

Diff for: install_magento.sh

+8-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
# vagrant provision --provision-with install_magento
44

5+
# Enable trace printing and exit on the first error
56
set -ex
67

78
# Determine external IP address
@@ -34,9 +35,10 @@ rm -f "${magento_dir}/app/etc/config.php"
3435
rm -f "${magento_dir}/app/etc/env.php"
3536

3637
# Create DB
37-
db_name="magento"
38-
mysql -u root -ppassword -e "drop database if exists ${db_name}; create database ${db_name};"
39-
mysql -u root -ppassword -e "GRANT ALL ON ${db_name}.* TO magento@localhost IDENTIFIED BY 'magento';"
38+
db_names=("magento" "magento_integration_tests")
39+
for db_name in "${db_names[@]}"; do
40+
mysql -e "drop database if exists ${db_name}; create database ${db_name};"
41+
done
4042

4143
# Install Magento application
4244
cd ${magento_dir}
@@ -55,8 +57,7 @@ admin_frontame="admin"
5557
install_cmd="./bin/magento setup:install \
5658
--db-host=localhost \
5759
--db-name=magento \
58-
--db-user=magento \
59-
--db-password=magento \
60+
--db-user=root \
6061
--backend-frontname=${admin_frontame} \
6162
--base-url=http://${HOST}/ \
6263
--language=en_US \
@@ -86,8 +87,8 @@ Access admin panel at http://${HOST}/${admin_frontame}/
8687
Don't forget to update your 'hosts' file with '${IP} ${HOST}'
8788
8889
[Optional] To finish developer environment set up:
89-
1. Please create new PHPStorm project using 'magento2ce' directory on your host
90+
1. Please create new PhpStorm project using 'magento2ce' directory on your host
9091
(this directory should already contain Magento repository cloned earlier)
9192
9293
2. Use instructions provided here https://github.com/paliarush/vagrant-magento/blob/master/docs/phpstorm-configuration.md
93-
to set up synchronization in PHPStorm (or using rsync) with ${magento_dir} directory"
94+
to set up synchronization in PhpStorm (or using rsync) with ${magento_dir} directory"

0 commit comments

Comments
 (0)