1 of 22

Slide Notes

DownloadGo Live

VLAD + xDebug + Drupal 8 + webprofiler

Published on Nov 19, 2015

No Description

PRESENTATION OUTLINE

VLAD + xDebug + Drupal 8 + webprofiler

A very handy setup for learning and developing

IF ON PUBLIC WIFi

downloading will be slow, and expensive
Photo by digitalnoise

VLAD + DRUPAL 8 + WEBPROFILER + drupal console + xDebug

A very handy setup for learning and developing

Some prerequisites

  • git
  • vagrant
  • virtualbox
  • A processor that supports virtualisation (as we use a 64-bit guest OS) - you may need to enable this in the BIOS
  • ansible
  • nfs
apt-get install nfs-common
apt-get install nfs-kernel-server

VLAD

Photo by phototouring

Download/Clone VLAD

Setup vlad_settings

  • Copy template_vlad_settings.php to vlad_settings (symlink to /docroot?)
  • Alter the webserver_hostname, webserver_hostname_aliases, boxipaddress, boxname
  • Add 'aux_synced_folder' then set 'aux_synced_folder' to '../aux_synced' and 'host_synced_folder' to '../docroot'
  • Any further config you might want (eg. varnish, solr)
git clone https://github.com/hashbangcode/vlad.git vlad

Note: remember indentations

Add Drupal 8

# Databases
dbname: ['vladdb', 'drupal8']
dbuser: 'drupal8'
mysql_root_password: 'October7th'

Note: remember indentations, they are important (2 spaces)

Some extra D8 settings are on the way:
https://github.com/hashbangcode/vlad/issues/305

A few extra vlad settings for D8

  • # Some extra D8 settings (https://github.com/hashbangcode/vlad/issues/305) drush_version: master vm_memory: 2048 vlad_drupal_install_version: 8 drush_version: 7.x drush_install_commands: - { name: 'coder', version: '-8.x-2.4'} - { name: 'site_audit', version: ''} - { name: 'registry_rebuild', version: ''}

Vagrant up

... and wait (possible a long time)
Photo by Leo Reynolds

Troubleshooting

  • You may need to manually install vagrant-triggers and vagrant-hostsupdater
vagrant plugin install vagrant-triggers

vagrant plugin install vagrant-hostsupdater

Install Drupal 8

You may want to use mysql workbench to check the DB has setup correctly

and D8 is born, next?

Photo by matt.farina

drupal console

Managing your site (like Drush)
Photo by David Masters

Install Drupal console

# Run this in your terminal to get the latest Console version:
curl http://drupalconsole.com/installer -L -o drupal.phar

# Accessing from anywhere on your system:
mv drupal.phar /usr/local/bin/drupal

# Apply executable permissions on the downloaded file:
chmod +x /usr/local/bin/drupal

# Copy configuration files to user home directory:
drupal init [--override]

# Update DrupalConsole to the latest version:
drupal self-update

Tips on usage

Web Profiler
(now in devel)

Performance monitor
Photo by ksyz

Installation

  • ssh into your vagrant box: vagrant ssh
  • Go to site docroot
  • Use console to download devel: drupal module:download devel
  • Then install: drupal module:install devel devel_generate devel_node_access webprofiler

Tips on usage

  • Get baseline for D8/server combo
  • Are particular views slow?
  • Slow queries?
  • Basic PHP config
  • Headers

XDEBUG (with phpstorm)

Debug known issues

Connect phpstorm to vagrant

  • click dropdown next to bug icon, and click configure
  • Choose 'php remote debug', and insert IP and directory for Drupal on server (use vagrant ssh to get this)
  • idekey=phpstorm
  • in chrome install the 'Xdebug helper' extension, and set its idekey to phpstorm (right click, config)
  • enable the extension

Tips on usage

  • Set a breakpoint on line51 of webprofilers cachebackendwrapper.php
  • click bug icon to start the debugging
  • Step through and look at variables in phpstorm (notice how often line 51 is called, and how bin changes)
  • ctrl + click to go into declaration
  • right clock object the create diagram to see full tree if complex