industrialise php ~ zendcon europe 2013

Post on 03-Jul-2015

7.208 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

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

TRANSCRIPT

 Industrialise  PHP  in  the  cloud  with  Windows  Azure

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

MICROSOFT  AZUREWhy  ?!

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

LIBRARIESIt’s  all  about  code

 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?

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PHP  FRAMEWORK  INTEROP  GROUPPHP  FIG

 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)

 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>

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PSR  #1  /  #2  –  Coding  Standard

• Understanding  syntax  vs  understanding  code  • Same  syntax  across  libraries

 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

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

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

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

COMPOSERA  revolution  in  the  PHP  world

 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

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�23

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PHP  ENVIRONMENTSRunning  the  code

 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  ?

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

VAGRANTvirtual  development  environments

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Vagrantfile

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

vagrant up

 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  ?

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PROVISIONINGAutomate  your  infrastructure

 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

 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/

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

VAGRANT  +  PUPPETAutomate  developer’s  work

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Vagrantfile

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

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

* just wait a few minutes

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�40

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

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

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�43

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�45

 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  …

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

CAPISTRANORemote  multi-­‐server  automation  tool

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

$ cap azure puppet deploy

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

JENKINSA  continuous  integration  server

 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

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Jenkins  Job

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

PRODUCTIONGoing  live

�64

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Industrialisation

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�66

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

FOLDER  STRUCTUREls  -­‐lsa  /myawesomeproject/

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

�68

 Industrialise  PHP  in  the  cloud  with                                                                    @  ZendCon  Europe

Select  your  own  tools

 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

Questions  ?

�71

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

top related