industrialise php ~ zendcon europe 2013

72
Industrialise PHP in the cloud with Windows Azure

Upload: ekino

Post on 03-Jul-2015

7.210 views

Category:

Technology


3 download

DESCRIPTION

The talk introduce processes to industrialise your PHP development, from code to production...

TRANSCRIPT

Page 1: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with  Windows  Azure

Page 2: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Who  ?

• Thomas  Rabaix  – Software  Architect  @  – Symfony  Expert  – Sonata  Project  lead  dev  – Social  – https://github.com/rande  – https://twitter.com/th0masr

Page 3: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

MICROSOFT  AZUREWhy  ?!

Page 4: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Industrialisation

• Respect  Standards  • Don’t  reinvent  the  wheel  • Create  a  valid  workflow  • Never  break  the  workflow  • Automate  the  workflow  • Be  lazy

Page 5: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

LIBRARIESIt’s  all  about  code

Page 6: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Libraries

• Foundation  behind  projects  • How  easy  a  library  can  be  reused  ?  • How  easy  a  library  can  be  integrated  into  your  project?

Page 7: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PHP  FRAMEWORK  INTEROP  GROUPPHP  FIG

Page 8: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Group  Members

• Agavi  ~  David  Zülke  (@dzuelke)  

• AWS  SDK  for  PHP  (Amazon  Web  Services)  ~  Michael  Dowling  (@mtdowling)  

• Apache  log4php  ~  Ivan  Habunek  (@ihabunek)  

• Assetic  and  Buzz  ~  Kris  Wallsmith  (@kriswallsmith)  

• Aura  Project  and  Solar  Framework  ~  Paul  M.  Jones  (@pmjones)  

• CakePHP  ~  Larry  Masters  (@PhpNut)  

• Composer  and  Packagist  ~  Jordi  Boggiano  (@seldaek)  

• Contao  Open  Source  CMS  ~  Leo  Feyer  (@leofeyer)  

• Doctrine  ~  Guilherme  Blanco  (@guilhermeblanco)  

• Drupal  ~  Larry  Garfield  (@Crell)  

• eZ  Publish  ~  Andre  Romcke  (@andrerom)  

• TYPO3  Flow  ~  Karsten  Dambekalns  (@kdambekalns)  

• Jackalope  ~  Lukas  Kahwe  Smith  (@lsmith)  

• Joomla  ~  Don  Gilbert  (@dilbert4life)  

• Laravel  ~  Taylor  Otwell  (@taylorotwell)  

• Lithium  ~  Nate  Abele  (@nateabele)  

• PEAR  ~  Brett  Bieber  (@saltybeagle)  

• phpBB  ~  Nils  Adermann  (@naderman)  

• phpDocumentor  ~  Mike  van  Riel  (@mvriel)  

• PPI  Framework  ~  Paul  Dragoonis  (@dr4goonis)  

• Propel  ~  William  Durand  (@couac)  

• PyroCMS  ~  Phil  Sturgeon  (@philsturgeon)  

• SabreDAV  ~  Evert  Pot  (@evertp)  

• SugarCRM  ~  John  Mertic  (@jmertic)  

• Symfony2  ~  Bernhard  Schussek  (@webmozart)  

• The  community  at  large  ~  Cal  Evans  (@CalEvans)  

• Yii  framework  ~  Alexander  Makarov@sam_dark)  

• Zend  Framework  2  ~  Pádraic  Brady  (@padraicb)  

• Zikula  ~  Karma  Dordrak  (@zikuladrak)

Page 9: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PSR  #0  -­‐  Autoloading  Standard• Are  you  still  using  include  in  your  project  ?  • Defines  how  class  can  be  loaded  • \<Vendor Name>\(<Namespace>\)*<Class Name>

Page 10: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PSR  #1  /  #2  –  Coding  Standard

• Understanding  syntax  vs  understanding  code  • Same  syntax  across  libraries

Page 11: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PSR  #3  –  LoggerInterface• Every  projects  need  logs  • Need  a  common  interface  to  write  log  • You  don’t  want  to  write  a  wrapper  for  each  library

Page 12: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Industrialisation

• Industrialisation  is  about  using  standards  • Share  the  same  rules    • if  as  a  vendor  you  want  your  code  to  be  used  • if  as  a  recruiter  want  new  people  to  get  into  a  project  quickly

Page 13: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

FRAMEWORKS  (AND  ALIKE)It’s  PHP  code  after  all

Page 14: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Select  your  own

• Zend  Framework  • Laravel  • Symfony2  • Silex  • CakePHP  • CodeIgniter  • Wordpress  • Drupal  • ezPublish  • Insert  your  favorite  solution �14

Page 15: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

COMPOSERA  revolution  in  the  PHP  world

Page 16: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Composer

• …  is  a  dependency  manager  tracking  local  dependencies  of  your  projects  and  libraries.  

• …  is  2  years  old  only  • …  is  a  revolution  in  the  PHP  world    – 18  894  packages    – 89  689  007  installed  packages  (since  2012-­‐04-­‐13)  !Default  definitions  available  on  packagist.org

Page 17: Industrialise PHP ~ ZendCon Europe 2013
Page 18: Industrialise PHP ~ ZendCon Europe 2013
Page 19: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Composer

• 99%  of  packages  are  hosted  on  Github  • Github  has  downtime  or  rate  limits  • Repositories  can  disappear  • Need  speed  • Security  Policies  !

• Mirror  Packagist's  definitions  and  Github’s  repositories!  

https://github.com/ekino/php-­‐mirroring

Page 20: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 21: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 22: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 23: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�23

Page 24: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PHP  ENVIRONMENTSRunning  the  code

Page 25: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Too  many  environments

• How  many  php  runtimes  do  you  have  ?  – cli,  php-­‐cgi,  php-­‐fpm,  mod_php5,  hhvm  

• How  many  distributions  do  you  have  ?  – Ubuntu,  debian,  redhat,  centos,  etc  ..  

• How  many  systems  are  required  by  the  project  ?  – mysql,  memcached,  varnish,  mongodb,  etc  …  

• How  long  does  it  take  to  introduce  a  new  developer  into  the  team  ?

Page 26: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

VAGRANTvirtual  development  environments

Page 27: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Vagrant

• Abstracted  layer  to  control  VM  – VirtualBox,  VMWare,  and  many  more  

• Can  boot  any  kind  of  distribution  to  match  client  requirements  • Simple  configuration  file,  but  powerful  features

Page 28: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Vagrantfile

Page 29: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

vagrant up

Page 30: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

• All  developers  can  now  use  the  same  distribution  • This  is  not  enough  – How  to  match  clients  system  requirements  ?  – How  to  avoid  complex  setup  done  by  each  developer  on  the  VM  ?

Page 31: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PROVISIONINGAutomate  your  infrastructure

Page 32: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Provisioning

• Define  system  configuration  • Apply  the  configuration  to  a  host  • Ensure  quick  system  installation  – Everything  is  in  the  code  – Definitions  are  stored  in  your  git  repository

Page 33: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Provisioning  :  Puppet

• Ruby  tools  • A  node  is  a  host  in  your  infrastructure  • Lots  of  modules  to  setup  system  –  apache,  apt,  composer,  concat,  exim,  java,  jenkins,  memcached,  mysql,  nginx,  php,  redis,  resolver,  ruby,  stdlib,  varnish,  wget,  and  many  more  …  

– https://forge.puppetlabs.com/

Page 34: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 35: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 36: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 37: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

VAGRANT  +  PUPPETAutomate  developer’s  work

Page 38: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Vagrantfile

Page 39: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

$ git clone git://mygit/myproject.git $ cd myproject $ vagrant up —provision *

* just wait a few minutes

Page 40: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�40

Page 41: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

QUALITY  ASSURANCEIs  my  code  working?  Are  the  client  requirements    working?

Page 42: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Unit  Tests

• Why  testing  ?  • ensure  the  code  is  working  as  expected  • allow  safe  refactoring  • Test  one  class  or  one  function  

• Different  solutions  • PHPUnit,  the  default  one  • Atoum,  an  alternative  • PHPSpec

Page 43: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�43

Page 44: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Functional  Tests

• Run  scenarios  depending  on  user’s  requirements  • Check  if  classes  work  properly  together  • Behat  +  Mink  • Run  http  requests  on  the  web  application  • Different  drivers:  Goutte,  Selenium,  Sahi,  Zombie

Page 45: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�45

Page 46: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Integration  Tests

• How  to  check  if  the  code  is  working  with  the  infrastructure  …  

• Run  tests  against  the  new  release  • Need  to  deploy  the  code  first  …

Page 47: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

CAPISTRANORemote  multi-­‐server  automation  tool

Page 48: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

• Deploy  code  into  remote  servers  • Task  can  be  run  in  parallel  on  different  remote  servers  • Task  definition  in  ruby  style  • Simple  commands,  but  powerful  options

�48

Page 49: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 50: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 51: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Azure

• Create  a  new  VM  for  the  integration  tests  • For  now  Azure  VMs  are  not  puppet  ready  – You  need  to  install  puppet  and  rubygems  – But  you  can  create  your  own  vhd  image  

• We  create  a  sonata-­‐dev  instance

Page 52: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 53: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 54: Industrialise PHP ~ ZendCon Europe 2013
Page 55: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

$ cap azure puppet deploy

Page 56: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

JENKINSA  continuous  integration  server

Page 57: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Jenkins

• Continuous  integration  server  • Run  tasks  and  publish  results  – Can  be  used  with  many  testing  frameworks  –Many  plugins

�57

Page 58: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 59: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 60: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Page 61: Industrialise PHP ~ ZendCon Europe 2013

Jenkins  Job

Page 62: Industrialise PHP ~ ZendCon Europe 2013
Page 63: Industrialise PHP ~ ZendCon Europe 2013
Page 64: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PRODUCTIONGoing  live

�64

Page 65: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Industrialisation

Page 66: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�66

Page 67: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

FOLDER  STRUCTUREls  -­‐lsa  /myawesomeproject/

Page 68: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�68

Page 69: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Select  your  own  tools

Page 70: Industrialise PHP ~ ZendCon Europe 2013

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PHP  industrialisation  is  about  …

Respecting  Standards  

Reusing  tools  

Selecting  your  own  tools  

Creating  a  valid  workflow  

Automating  the  workflow

Page 71: Industrialise PHP ~ ZendCon Europe 2013

Questions  ?

�71

Page 72: Industrialise PHP ~ ZendCon Europe 2013

Going  further  @  ZendCon

• Vagrant,  puppet  &  chef  for  beginners  -­‐  Thijs  Fery    • Compose  this!  -­‐  Matthew  Weier  O’Phinney    • Phing  for  power  users  -­‐  Stephan  Hochdörfer  • Jenkins  entwined  with  deployment  and  pragmatism  -­‐  Eric  Ritchie    

• Beyond  PHP:  it  is  not  (just)  about  the  code!  -­‐  Wim  Godden  

• Essential  Git  for  Developers  -­‐  Adam  Culp  

�72