Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Local development improvements

wernerkrauss
September 23, 2020

Local development improvements

Talk given at https://2020.stripecon.eu

TwistedBytes' vagrant box: www.derkbox.com

wernerkrauss

September 23, 2020
Tweet

More Decks by wernerkrauss

Other Decks in Programming

Transcript

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

    View Slide

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

    View Slide

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

    View Slide

  4. Vagrant

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  8. The Box

    View Slide

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

    View Slide

  10. Configure box via Vagrantfile

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  15. The IDE

    View Slide

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

    View Slide

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

    View Slide

  18. 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)

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide