This page lists a few extra VVV configurations that can be useful in some scenarios. For example, how to set up a new project in PHPStorm for WooCommerce with Vagrant integration.
Table of Contents
Activate Xdebug in VVV
Running xdebug_on
inside Vagrant seems to be broken for me (Peter) as of 2019-05-14, so here are manual steps:
-
Copy and paste output from phpinfo() to Xdebug wizard, analyze and check step about editing the php.ini file (step 9 in my case).
-
Check if
/usr/lib/php/*/xdebug.so
is present in the VM (it should be):$ ls /usr/lib/php/20170718/xdebug.so
-
Update
/etc/php/*/fpm/php.ini
inside the Vagrant VM according to instructions from the Xdebug wizard website.$ sudo tee -a /etc/php/7.2/fpm/php.ini >/dev/null <<'EOF' [xdebug] zend_extension = /usr/lib/php/20170718/xdebug.so EOF
-
Restart php service
$ sudo service php7.2-fpm restart
-
Check phpinfo()--it should contain a new section for Xdebug
Email setup in VVV
- Standard mailhog catching all emails going out of virtual machine is available at http://vvv.test:8025/.
- If you want to relay emails via the gmail SMTP server, follow the steps below:
Setting up Gmail SMTP server
- Create a new gmail account and allow access for less secure apps
All of the below steps should be performed in the Vagrant VM:
-
Edit
/etc/php/7.2/fpm/conf.d/20-mailhog.ini
and replace existing sendmail path withsendmail_path = "/usr/sbin/sendmail -t -i"
-
Update mail config:
sudo nano /etc/postfix/main.cf
and replace therelayhost =
line with these:relayhost = [smtp.gmail.com]:587 smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt smtp_use_tls = yes
-
sudo nano /etc/postfix/sasl_passwd
and add this line:[smtp.gmail.com]:587 username@gmail.com:password
-
Fix access, apply settings.
sudo chmod 400 /etc/postfix/sasl_passwd sudo postmap /etc/postfix/sasl_passwd sudo /etc/init.d/postfix reload
-
Test that everything works by creating a new WP account and then using the
Lost your password?
link on http://one.wordpress.test/wp-login.php or, on a more low-level by running the following command from the Vagrant VMecho "Subject: test" | /usr/lib/sendmail -v dest@email.com
-
If you don't receive the message, inspect the mail log:
tail -n 30 /var/log/mail.log
-
Don't forget to install Stop emails if you plan to generate products and orders using WC Smooth Generator
Setting up a project in PHPStorm
-
Create a new WordPress project, I prefer to point it at the root WP folder to enable debugging through the WordPress code as well.
-
PHPStorm should ask if you want to create project from existing sources.
-
Go to Preferences: Tools > Vagrant--set up instance folder and box.
-
You can set up vagrant instance also in the Tools > SSH Terminal section.
-
Preferences: Language > PHP and set up remote PHP executable and language level.
-
Preferences: Language > PHP > Servers and set host to current host (one.wordpress.test), check Use path mappings and set up the path mapping.
-
Preferences: Language > PHP > Frameworks and enable WP integration.
-
Preferences: Language > PHP > Debug and click on blue Validate link, set up correct URL to validation script (http://one.wordpress.test/) and click on Validate button, you probably need to fix two settings in php.ini.
-
Update php.ini according to instructions (in the VM).
$ sudo tee -a /etc/php/7.2/fpm/php.ini >/dev/null <<'EOF' xdebug.remote_host='192.168.50.1' xdebug.remote_enable=1 EOF $ sudo service php7.2-fpm restart
-
Preferences: Version Control and add WooCommerce directory as a VCS root.
-
Optionally, create a new GH token and add it under Preferences: Version Control > GitHub to allow pushing to GH.
-
To make debugging work, you might want to disable profiling tool Tideways which prepends a php file to each file that runs using php.ini's auto prepend file directive. To remove the auto-prepend, you can use the following updates to ini files:
$ sudo tee /etc/php/7.2/fpm/conf.d/20-xhgui.ini >/dev/null <<'EOF' ; auto_prepend_file=/srv/tideways-header.php EOF $ sudo tee /etc/php/7.2/fpm/conf.d/20-tideways_xhprof.ini >/dev/null <<'EOF' ; extension=tideways_xhprof.so EOF $ sudo service php7.2-fpm restart
-
Alternatively, you can copy the tideways PHP file over to your local machine and map it in the path mappings for PHPDebug (confirmed to work by Rodrigo and Peter).
Contribution
- Set up development environment
- Our Git Flow
- SCSS and JS minification
- Naming conventions
- CSS SASS coding guidelines and naming conventions
- Critical Flows
- API Critical Flows
- String localisation guidelines
- Translating WooCommerce
- Deprecation in core
- Adding Actions and Filters
- Common Issues
- Writing high-quality testing instructions
Release Notes
- Release Testing Instructions
- 3.6.x notes/FAQ
- 2.6.x to 3.0.0 Developer Migration Notes
- Select2 fields not working in 3.0.x
- Thumbnail Image Regeneration in 3.3+
- Customizing image sizes in 3.3+
REST API and CLI
CRUD & Data Descriptions
- Database Description
- CRUD Objects in 3.0
- Order and Order Line Item Data
- Coupon Data
- Customer Data
- Product Data
- Data Stores
Internal APIs
Theming
- Enabling product gallery features (zoom, swipe, lightbox)
- Template File Guidelines for Devs and Theme Authors
Examples / Guides
WooCommerce is an open source commerce platform built for WordPress and lovingly crafted by Automattic and the WooCommerce community 💜. Come and work with us!