Skip to content

Extra VVV Configurations

Peter Fabian edited this page Nov 14, 2019 · 3 revisions

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:

  1. Copy and paste output from phpinfo() to Xdebug wizard, analyze and check step about editing the php.ini file (step 9 in my case).

  2. Check if /usr/lib/php/*/xdebug.so is present in the VM (it should be):

    $ ls /usr/lib/php/20170718/xdebug.so
  3. 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
  4. Restart php service

    $ sudo service php7.2-fpm restart
  5. Check phpinfo()--it should contain a new section for Xdebug

Email setup in VVV

  1. Standard mailhog catching all emails going out of virtual machine is available at http://vvv.test:8025/.
  2. If you want to relay emails via the gmail SMTP server, follow the steps below:

Setting up Gmail SMTP server

  1. Create a new gmail account and allow access for less secure apps

All of the below steps should be performed in the Vagrant VM:

  1. Edit /etc/php/7.2/fpm/conf.d/20-mailhog.ini and replace existing sendmail path with sendmail_path = "/usr/sbin/sendmail -t -i"

  2. Update mail config: sudo nano /etc/postfix/main.cf and replace the relayhost = 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

  3. sudo nano /etc/postfix/sasl_passwd and add this line:

    [smtp.gmail.com]:587 [email protected]:password

  4. Fix access, apply settings.

    sudo chmod 400 /etc/postfix/sasl_passwd
    sudo postmap /etc/postfix/sasl_passwd
    sudo /etc/init.d/postfix reload
    
  5. 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 VM

    echo "Subject: test" | /usr/lib/sendmail -v [email protected]
    
  6. If you don't receive the message, inspect the mail log:

    tail -n 30 /var/log/mail.log
    
  7. 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

  1. Create a new WordPress project, I prefer to point it at the root WP folder to enable debugging through the WordPress code as well.

  2. PHPStorm should ask if you want to create project from existing sources.

  3. Go to Preferences: Tools > Vagrant--set up instance folder and box.

  4. You can set up vagrant instance also in the Tools > SSH Terminal section.

  5. Preferences: Language > PHP and set up remote PHP executable and language level.

  6. Preferences: Language > PHP > Servers and set host to current host (one.wordpress.test), check Use path mappings and set up the path mapping.

  7. Preferences: Language > PHP > Frameworks and enable WP integration.

  8. 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.

  9. 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
  10. Preferences: Version Control and add WooCommerce directory as a VCS root.

  11. Optionally, create a new GH token and add it under Preferences: Version Control > GitHub to allow pushing to GH.

  12. 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
  13. 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).

Clone this wiki locally