Slide 1

Slide 1 text

Local development improvements TwistedBytes’ Vagrant Box & PHPStorm Tips and Tricks

Slide 2

Slide 2 text

Who am I? ● Werner M. Krauß ● Living in Bad Ischl, Austria ● wmk on slack ● PHP since 1998 ● Freelancer since 2006 (netwerkstatt) ● Silverstripe since 2009 (V 2.3) ● Creator of www.silverstrip.es

Slide 3

Slide 3 text

What’s this talk about? ● My development setup ○ PHPStorm ○ Vagrant ○ Derk’s TwistedBytes Vagrant box ● Cool settings to ease the daily development tasks ● Tips and tricks

Slide 4

Slide 4 text

Vagrant

Slide 5

Slide 5 text

Pros and Cons + easy set up virtual machine for local development + same development environment for the whole team + many ways to configure it + preconfigured boxes with huge functionalities - slow shared folder on windows - upgrading the box destroys it’s database

Slide 6

Slide 6 text

What do we need? ● PHPStorm / Intellij Idea ● VirtualBox and Vagrant ● Hostmanager plugin for nice local URLs ● TwistedBytes’ webserver box aka DerkBox(box templates)

Slide 7

Slide 7 text

PHPStorm Vagrant tools ● The IDE can control and communicate with the VM ● Shortcuts for starting, stopping, suspending, resuming, reloading and destroying the VM ● can easily connect to the VM and configure paths, PHP interpreter, composer, PHPUnit etc...

Slide 8

Slide 8 text

The Box

Slide 9

Slide 9 text

Eat fresh: only the best ingredients ● Apache with PHP 5.6, 7.0, …, 7.4, 8.0-beta ● MariaDB, PostgreSQL ● PhpMyAdmin ● Mailcatcher ● redis ● sspak

Slide 10

Slide 10 text

Configure box via Vagrantfile ●

Slide 11

Slide 11 text

Box Configuration ● a bunch of config files in different directories ● configure webserver root and https ● install additional packages ● Switch PHP versions on the fly ● Switch xdebug on and off ● import/export databases ● folder for PHPMyAdmin’s database imports

Slide 12

Slide 12 text

PMA: PhpMyAdmin ● available under “/pma” ● Import dumps from “vagrant/pma_upload”

Slide 13

Slide 13 text

Built in DB import & export ● can be triggered from vagrant/private/ mysqldump-trigger.conf and mysqlload-trigger.conf ● saves and loads dumps in own folder

Slide 14

Slide 14 text

Still not enough? ● add your own binaries to vagrant/private/bin

Slide 15

Slide 15 text

The IDE

Slide 16

Slide 16 text

Configuring PHPStorm ● Add box as remote PHP interpreter ● Setup Composer ● Xdebug & PHPUnit path mapping

Slide 17

Slide 17 text

Composer ● manage packages on the box ● Installs via remote interpreter on the box ● no need to match the local PHP version ● caveat: github token for composer might be needed

Slide 18

Slide 18 text

Xdebug ● Cannot live without it ● Easy mapping with PHPStorm ● Slows down PHP Interpreter ● Can be switched off in the box if not needed (e.g. for frontend work)

Slide 19

Slide 19 text

PHPUnit ● Run tests remotely from your IDE ● nice output ● one click to the source of errors ● possibility to debug unit tests

Slide 20

Slide 20 text

remote tools run commands on the vagrant box with one click ● flush caches ○ use “silverstripe-cache” folder in project root ● vendor expose ● dev/build ● sake

Slide 21

Slide 21 text

Advanced Change xdebug settings for ngrok ● php.ini changes can be done in vagrant/config/ php-fpm-pool.conf

Slide 22

Slide 22 text

Thank you www.silverstrip.es www.netwerkstatt.at