The Modern Developer Toolbox

Preview:

DESCRIPTION

In recent years there has been a tremendous amount of progress and innovation around tools and applications available to web developers that improve the quality, efficiency and speed of our applications, and it is hard to keep up with all of it.

Citation preview

The Modern Developer Toolbox

Pablo Godel @pgodel https://joined.in/11798

Photo by https://www.flickr.com/photos/zergev/

Hi, I am Pablo.

Hi, I am Pablo. !

@pgodel

The Modern Developer Toolbox

Modern?

The Modern Developer Toolbox

[root@prod] # vi index.php

The Modern Developer Toolbox

Never stop !improving

The Modern Developer Toolbox

The Toolbox

The Modern Developer Toolbox

Development environment

The Modern Developer Toolbox

Development environment !

Testing

The Modern Developer Toolbox

Development environment !

Testing !

Debugging

The Modern Developer Toolbox

Development environment !

Testing !

Debugging !

Profiling

The Modern Developer Toolbox

Development environment !

Testing !

Debugging !

Profiling !

Deployment

The Modern Developer Toolbox

Development environment !

Testing !

Debugging !

Profiling !

Deployment !

Logging

The Modern Developer Toolbox

Development environment !

Testing !

Debugging !

Profiling !

Deployment !

Logging !

Monitoring

The Modern Developer Toolbox

Development Environment

Development Environment

Everything starts with a great development environment

Choosing an OS

Development Environment

The Modern Developer Toolbox

Rule #1

Development Environment

The Modern Developer Toolbox

Rule #1: Stay close to Production

Development Environment

The Modern Developer Toolbox

Rule #2

Development Environment

The Modern Developer Toolbox

Rule #2: Ditch Windows

Development Environment

The Modern Developer Toolbox

Rule #3

Development Environment

The Modern Developer Toolbox

Rule #3: Don’t forget Rule #2

Development Environment

The Modern Developer ToolboxDevelopment Environment

The Modern Developer Toolbox

Automate your setup

Development Environment

The Modern Developer Toolbox

Automate your setup !

#1 Store your dot-files in Git/GitHub

Development Environment

The Modern Developer Toolbox

https://github.com/pgodel/dotfiles

Dot files .profile / .bash_profile / .bashrc .gitconfig .gitignores.ssh/config

https://github.com/everzet/dotfiles

Development Environment

The Modern Developer Toolbox

Automate your setup !

#2 Automate your software installation

Development Environment

The Modern Developer Toolbox

Homebrew!!

• hhvm • wget • git • tmux • ssh-copy-id • brew-cask • ansible

Development Environment

The Modern Developer Toolbox

Even .dmg’s! !

!

• google-chrome • vagrant • virtualbox • iterm2 • alfred • phpstorm

Development Environment

$ brew cask install …

!https://github.com/caskroom/homebrew-cask

The Modern Developer Toolbox

Run Linux natively / locally !

• REMI repo for CentOS • PPAs for Ubuntu / Debian

Development Environment

Installing PHP

The Modern Developer Toolbox

Run Linux on VPS / remote !

• REMI repo for CentOS • PPAs for Ubuntu / Debian

Development Environment

Installing PHP

The Modern Developer Toolbox

Mac OSX !

• MAMP • Liip PHP installer

Development Environment

Installing PHP

The Modern Developer Toolbox

Virtual Machine • VirtualBox / Parallels / VMware • Vagrant • Docker

Development Environment

Installing PHP

The Modern Developer Toolbox

PHARS!!

• Composer • PHPUnit • behat • WP-CLI • versionscan

Development Environment

The Modern Developer Toolbox

Vagrant!!

• PuPHPet • Phansible

Development Environment

The Modern Developer ToolboxDevelopment Environment

VagrantHost

Vagrant

VM VM VM

Web Server

DB Server

App Server

The Modern Developer ToolboxDevelopment Environment

DockerHost

Docker client

CVM

Web Server

DB Server

App Server

C C

The Modern Developer ToolboxDevelopment Environment

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

The Modern Developer ToolboxDevelopment Environment

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

The Modern Developer ToolboxDevelopment Environment

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Host

C

VM

Web Server

DB Server

App Server

C C

The Modern Developer ToolboxDevelopment Environment

DockerHost

Docker client

C

VM

Web Server

DB Server

App Server

C C

Host

C

VM

Web Server

DB Server

App Server

C C

Host

C

Web Server

DB Server

App Server

C C

Docker Kernel

The Modern Developer Toolbox

$ ansible-playbook -i inventories/dev \ playbook.yml -v -K

https://github.com/pgodel/ansible-local-dev

Development Environment

The Modern Developer Toolbox

Use the right Editor/IDE for you

Development Environment

The Modern Developer Toolbox

Choose the right Editor/IDE for you!!

• PHPStorm • Zend Studio • TextMate • Vim

Development Environment

The Modern Developer Toolbox

Choose the right Editor/IDE for you!!

• PHPStorm!• Zend Studio • TextMate • Vim

Development Environment

The Modern Developer Toolbox

Choose the right Editor/IDE for you!!

• PHPStorm!• Fast • Syntax highlighting with PHP 5.6 • Git diffs and other actions • Breakpoints • and much more!

!

!

Development Environment

Setting up SSH

$ ssh-keygen -t dsa ~/.ssh/id_dsa.pub !

$ ssh-copy-id user@remote-host ~/.ssh/authorized_keys ~/.ssh/authorized_keys2 !

$ ssh-add

Development Environment

Host * ForwardAgent yes Port 22123 !

Host gh HostName github.com Port 22 PreferredAuthentications publickey IdentityFile ~/.ssh/me_rsa

Development Environment

Setting up SSH

~/.ssh/config

Virtual Document RootUseCanonicalName Off !VirtualDocumentRoot /var/www/vhosts/%0/web !<Location /var/www/vhosts> AllowOverride All Options +FollowSymLinks </Location>

example.com => /var/www/vhosts/example.com/webexample2.com => /var/www/vhosts/example2.com/web

Development Environment

The Modern Developer Toolbox

Testing

Testing!

!

• Unit testing with PHPUnit

Testing!

!

• Unit testing with PHPUnit • BDD with Behat

Testing!

!

• Unit testing with PHPUnit • BDD with Behat • Git hooks + php -l

Testing!

!

• Unit testing with PHPUnit • BDD with Behat • Git hooks + php -l • Jenkins

Testing!

!

• Unit testing with PHPUnit • BDD with Behat • Git hooks + php -l • Jenkins • Travis CI

!

Testing!

!

• Unit testing with PHPUnit • BDD with Behat • Git hooks + php -l • Jenkins • Travis CI • JoliCI

!

!

• phpmd / PHP Depend • PhpMetrics • SensioLabs Insight • Scrutinizer

Testing

The Modern Developer Toolbox

Debugging

print_r($data);

Debugging

LadyBug<?php $var = array( array( 'name' => 'Raul', 'age' => 29 ), array( 'name' => 'John', 'age' => 27 ) ); !ladybug_dump($var)

Debugging

LadyBug

Debugging

XDebug + PHPStorm

Debugging

The Modern Developer Toolbox

Debug CLI commands with PHPStorm !

Development Environment PRO TIP

$ export \ XDEBUG_CONFIG=“idekey=PHPSTORM"

Symfony Developer Toolbar

Debugging

Zend Studio + Zend Server + Z-RayDebugging

The Modern Developer Toolbox

Profiling

Profiling!

!

XDebug

Profiling!

!

XHProf + XHProf.io

Profiling!

Commercial options !

• Zend Server • SensioLabs Profiler (coming soon)

The Modern Developer Toolbox

Deployment

Deployment

• Capistrano (Ruby) / Capifony • Fabric (Python) • Idephix (PHP) • Magellanes (PHP) • Deployer (PHP) • Laravel / envoy (PHP) • Rocketeer (PHP) • Ansible (YAML)

Common steps

Deployment

Deployment!

!

• Define hosts

Deployment!

!

• Define hosts • Define tasks / actions

Deployment!

!

• Define hosts • Define tasks / actions • Run process

Deployment!

!

• Define hosts • Define tasks / actions • Run process • Safe operation

Deployment!

!

• Define hosts • Define tasks / actions • Run process • Safe operation • Migrations

Deployment!

!

• Define hosts • Define tasks / actions • Run process • Safe operation • Migrations • Rollbacks

Deploying with

Deployment

Deployment with Ansible!

!

Define hosts[webservers] foo.example.com bar.example.comwww[01:50].example.com ![dbservers] one.example.com two.example.com three.example.com

Deployment with Ansible!

!

Define tasks / actions--- - hosts: webservers vars: http_port: 80 max_clients: 200 remote_user: root tasks: - name: ensure apache is at the latest version yum: pkg=httpd state=latest - name: write the apache config file template: src=/srv/httpd.j2 dest=/etc/httpd.conf notify: - restart apache - name: ensure apache is running service: name=httpd state=started

Deployment with Ansible!

!

Define tasks / actions- hosts: webservers roles: - { role: servergrove.symfony2, symfony2_project_root: /var/www/vhosts/example.com/, symfony2_project_name: demo, symfony2_project_branch: master , symfony2_project_release: 1 }

Deployment with Ansible!

!

Run process

$ ansible-playbook -i inventories/servers \ playbook.yml -v

Deployment with Ansible!

!

Run process

Effing Package Management

https://github.com/jordansissel/fpm

Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.

fpm -s dir -t rpm -n "webapp" -v 1.0 /var/www/webapp !fpm -s dir -t deb -a all -n webapp -v 1.0 /etc/apache2/conf.d/my.conf /var/www/webapp

Deployment

The Modern Developer Toolbox

Logging

tail -f /var/log/*

Logging

tail -f /var/log/* | grep “Fatal error”

Logging

Logging

App / Logstash

Redis Logstash filter/processor

ElasticSearch Kibana

App / Logstash App / Logstash

Logstash + ElasticSearch + Kibana

Monolog

Logging

use Monolog\Logger; use Monolog\Handler\StreamHandler; !// create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); !// add records to the log $log->addWarning('Foo'); $log->addError('Bar');

Logging

!

• Rotates logs • Syslog / AMQP • Email / Chat servers • Redis / MongoDB / ElasticSearch • NullHandler • FingersCrossedHandler

Monolog

Logstash

Logging

input { file { path => “/var/log/apache2/access_log” } } output { elasticsearch { host => localhost } }

Kibana

Logging

The Modern Developer Toolbox

Monitoring

Monitoring

Measure everything!

Monitoring

App

StatsD Graphite

Grafana

App App

StatsD + Graphite + Grafana

StatsD + liuggio/statsd-php-client

$ composer require liuggio/statsd-php-client:dev-master

Monitoring

$sender = new SocketSender(/*'localhost', 8126, 'udp'*/); !$client = new StatsdClient($sender); $factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData'); !// create the data with the factory $data[] = $factory->timing('usageTime', 100); $data[] = $factory->increment('visitor'); $data[] = $factory->decrement('click'); $data[] = $factory->gauge('gaugor', 333); $data[] = $factory->set('uniques', 765); !// send the data as array or directly as object $client->send($data);

Monitoring

StatsD + liuggio/statsd-php-client

$data[] = $factory->timing('usageTime', 100);!!

// send the data as array or directly as object $client->send($data);

Monitoring

StatsD + liuggio/statsd-php-client

$data[] = $factory->increment('visitor');!!

// send the data as array or directly as object $client->send($data);

Monitoring

StatsD + liuggio/statsd-php-client

$data[] = $factory->decrement('click');!!

// send the data as array or directly as object $client->send($data);

Monitoring

StatsD + liuggio/statsd-php-client

$data[] = $factory->gauge('gaugor', 333);!!

// send the data as array or directly as object $client->send($data);

Monitoring

StatsD + liuggio/statsd-php-client

Graphite

Monitoring

Graphite

Monitoring

Grafana

Monitoring

<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .your_domain.com </Location> !ExtendedStatus On

Apache Requests

Monitoring

Apache Requests

Monitoring

MonitoringCPU / Memory / IOtop

Monitoring

IOiotop

The Modern Developer Toolbox

https://www.flickr.com/photos/jaquiza

The Modern Developer Toolbox

Questions!

The Modern Developer Toolbox

!

!

!

!

!

!

https://joind.in/11798 http://slideshare.net/pgodel

@pgodel

Thank you! Rate me please!

Recommended