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

ぼくの考えたさいきょうの開発フロー - PHP編

ぼくの考えたさいきょうの開発フロー - PHP編

PHPカンファレンス関西 2014

481a460d2008ec84e545cb877896d08b?s=128

YutaAdachi

June 28, 2014
Tweet

Transcript

  1. ΅͘ͷߟ͍͖͑ͨ͞ΐ͏ͷ։ൃϑϩʔ PHPฤ Yuta Adachi

  2. ࣗݾ঺հ ҆ୡ ༐ଠ (@UAdachi) ! ग़਎ɿౡࠜݝদߐࢢ ͓࢓ࣄɿChatWork ΠϯϑϥνʔϜ ! ڵຯ͋Δ͜ͱɿυϝΠϯۦಈઃܭɺScalaɺςχε

    (΢Οϯϒϧυϯ։࠵த) !
  3. IUUQTDJSDMFDJDPN

  4. ͓඼ॻ͖ • ։ൃϑϩʔΛ࠷దԽ͍ͯ͘͠໨త • ։ൃ؀ڥ • ίϛϡχέʔγϣϯ • CI •

    σϓϩΠ
  5. ໨త ! • ։ൃͷߴ଎Խ • ΦϖϨʔγϣϯϛεͷ༧๷ • ϓϩμΫτͷ඼࣭޲্ + ՄࢹԽ

  6. ։ൃ؀ڥ

  7. Ͳ͏΍ͬͯߏஙͯ͠·͔͢ʁ • Vagrantͬͯ࢖ͬͯ·͔͢ʁ

  8. ϝϯςφϯε • ։ൃ؀ڥͩͬͯߋ৽͞Εଓ͚Δ • ߏஙखॱॻΛ࡞Δͷେม " εΫϦʔϯγϣοτʹ໼ҹॻ͍ͯɺઆ໌จΛఴ͑ͯ…

  9. ʮԶͷ؀ڥʯ໰୊ ྫ. Aʮಈ͔Ͷʔʯ BʮԶͷ؀ڥͩͱಈ͘ʯ Cʮchown nginx:nginx /var/cache/nginx ʁʯ

  10. ։ൃ؀ڥ as Code • खॱॻΛίʔυʹஔ͖׵͑Δ " ߏ੒؅ཧπʔϧ (Ansible, Chef, SaltStack)

    • VirtualBox + Vagrant + AnsibleͷΠϯετʔϧ " Brewfile
  11. ։ൃ؀ڥʹԿΛೖΕ͓ͯ͘ʁ • ։ൃʹඞཁͳϛυϧ΢ΣΞ " PHP5.5, MySQL, memcached, redis-server • ศརπʔϧ

    " git, tcpdump, netcat, wget, zsh • δϣʔΫπʔϧ " sl
  12. ηοτΞοϓ $ git clone {repos} $ brew bundle $ vagrant

    up IUUQTHJUIVCDPNBEBVMBSBWFMQMBUGPSN
  13. ։ൃ؀ڥͷߋ৽ • νϟοτͰΞφ΢ϯε + λεΫԽ

  14. None
  15. ߋ৽खॱ • มߋՕॴ͕ଟ͍৔߹ $ git pull $ vagrant destroy $

    vagrant up
  16. ߋ৽खॱ • ͪΐͬͱͨ͠มߋ $ ./update ࣮ࡍ͸ #ͷΑ͏ͳίϚϯυΛ·ͱΊͯΔ͚ͩ $ git pull

    $ ansible-playbook site.yml —tags nginx
  17. ։ൃ؀ڥͷςετ • ςετ " serverspecͰςετ

  18. ։ൃ؀ڥͷςετ • ςετ " ࠶ߏங͢Δςετ $ vagrant destroy && vagrant

    up && rake spec " ႈ౳ੑͷνΣοΫ $ vagrant provision && vagrant provision && rake spec " ਓபνΣοΫ ਓபؾ࣭ͳΤϯδχΞʹ͓ࢼ͠ར༻ͯ͠΋Β͏
  19. ։ൃ؀ڥͷCI • ։ൃ؀ڥ΋CI͠Α͏ʂ " (ํ๏͸ޙ΄Ͳ)

  20. ίϛϡχέʔγϣϯ

  21. νϟοτ • ChatWork

  22. ϨϏϡʔ • ϨϏϡΞʔʹλεΫΛৼΔɺݻఆԽͤ͞ͳ͍ " ৄͦ͠͏ͳਓʹґཔ, ෳ਺ਓʹґཔ΋ !

  23. ௨஌ • ϓϧϦΫΤετ • CIͰςετʹࣦഊ • τϐοΫϒϥϯν͕Ϛʔδ͞Εͨ • εςʔδϯά؀ڥ͕ߋ৽ •

    ϦϦʔε
  24. ෦׆ • ݴޠɺΤσΟλɺπʔϧɺOSɺ… ͳΜͰ΋OK • ࠔͬͨͱ͖͸෦׆Ͱ࣭໰ " ୭͔ৄ͍͠ਓ͕ڭ͑ͯ͘ΕΔ (ࣾ಺Stack Overflow)

    • ৽ண৘ใͷڞ༗
  25. ෦׆

  26. None
  27. None
  28. None
  29. ܧଓతΠϯςάϨʔγϣϯ

  30. CIαʔϏε͍Ζ͍Ζ • Travis CI • CircleCI • Shippable • wercker

    • Codeship
  31. Travis CI • ศརͳͱ͜Ζ " composer.phar͕༻ҙ͞ΕͯΔ " phpenv (5.3ʙ5.6), hiphop

    " sudo͕࢖͑Δ
  32. Travis CI • composer͕༧Ί༻ҙ͞Ε͍ͯΔ " Ͱ΋ $ composer self-update ͸ඞཁ

  33. Travis CI • /usr/bin/php —-version " HipHop VM

  34. CircleCI • όʔδϣϯͷબ୒ࢶ͕๛෋ " 5.3.3, 10, 20, 25 " 5.4.4,

    5, 6, 7, 8, 9, 10, 11, 12, 13… " 5.5.0, 2, 3, 7, 8, 11 ! • 5.6ɺhiphop͸༻ҙ͞Ε͍ͯͳ͍ IUUQTDJSDMFDJDPNEPDTFOWJSPONFOUQIQ
  35. CircleCI • ϏϧυޙʹSSHͰϩάΠϯͰ͖Δ • sudoͰ͖ͳ͍

  36. wercker • ࣗલͰboxΛ༻ҙͰ͖Δ • Vagrant + Ansible + serverspecೖΕͨbox "

    EC2΍DigitalOceanʹεϙοτΠϯελϯε " AnsibleͷϓϨΠϒοΫ(ChefͷϨγϐ)ΛCI
  37. CIαʔϏε for PHPer • scrutinizer-ci • SensioLabsInsight

  38. scrutinizer-ci • ΠϯεϖΫγϣϯಛԽ • ςετ&ΧόϨοδ • ιϑτ΢ΣΞϝτϦΫεɺॏෳ౓ͷଌఆ • ඼࣭ͷఆྔԽɾՄࢹԽ

  39. scrutinizer-ci • PHPUnit & ΧόϨοδ (xdebug.so) • php-code-sniffer, php-cs-fixer •

    phpcpd, phpmd, phploc, pdepend • sensiolabs security checker (ޙ΄Ͳ) " ࣗ෼Ͱ༻ҙ͠ͳͯ͘ྑ͍!!!
  40. scrutinizer-ci • ஗͍ " ϫʔΧʔͷੑೳ͕ѱ͍ (༧૝)

  41. scrutinizer-ci

  42. scrutinizer-ci • ༗ྉϓϥϯͩͱίϯςφ΋଎͍ (ʁ) • ϝτϦΫεऩूͷͨΊ͚ͩʹ࢖͏ͷ΋͋Γ͔΋ " ςετ͸Travis CIͱ͔werckerͰճ͢

  43. SensioLabsInsight • ΠϯεϖΫγϣϯʹಛԽ • ηΩϡϦςΟνΣοΫ΋ॆ࣮͍ͯ͠Δ

  44. SensioLabsInsight • ϓϦϖΞʔυεςʔτϝϯτΛ࢖༻ͯ͠ͳ͍ΫΤϦ • XSS • σόοάϓϦϯτ (var_dump, print_r) •

    eval() • …
  45. SensioLabsInsight

  46. ΧόϨοδϨϙʔτ scrutinizer-ci or coveralls

  47. Coveralls

  48. Coveralls ೔ຊޠରԠŵŦƄō?(ɾ㱼ɾ )ͬ/႘˶ˑŧƃ

  49. ґଘϥΠϒϥϦͷ؅ཧ • composer.lock͸͍ͭΞοϓσʔτ͢Δʁ !

  50. ґଘϥΠϒϥϦͷ؅ཧ ߋ৽͕ཷ·Δ # composer update # git diff # ා͘ͳͬͯఘΊΔ

    # ͞Βʹཷ·Δ
  51. VersionEye IUUQTXXXWFSTJPOFZFDPN

  52. VersionEye • composer.jsonΛνΣοΫ͠ɺߋ৽͕͋Ε͹௨஌ " νΣοΫִؒ͸Daily, Weekly, Monthly͔Βબ୒Մೳ • API΋ఏڙ͞Ε͍ͯΔ "

    CIαʔϏεͰϏϧυ࣌ʹνΣοΫͰ͖Δ
  53. None
  54. VersionEye • ґଘؔ܎ΛՄࢹԽͯ͘͠ΕΔ

  55. None
  56. ηΩϡϦςΟΞοϓσʔτ • ੬ऑੑ৘ใͷΩϟονΞοϓ " ͜Ε΋CI࣌ʹͰ͖ͨΒخ͍͠

  57. Security Advisories Checker IUUQTTFDVSJUZTFOTJPMBCTPSHDIFDL

  58. Security Advisories Checker • ੬ऑੑͷ͋ΔϥΠϒϥϦΛ࢖͍ͬͯͳ͍͔νΣοΫ " composer.lockͰ൑அ • Web /

    Cli / API͕༻ҙ͞Ε͍ͯΔ " CIαʔϏεͰϏϧυ࣌ʹνΣοΫͰ͖Δ
  59. None
  60. ηΩϡϦςΟΞοϓσʔτ • Security Advisories Checker " ͋͘·ͰґଘϥΠϒϥϦ͕ର৅ • JVN͸νΣοΫ͠·͠ΐ͏

  61. CIͷ·ͱΊ

  62. CIͰ΍Γ͍ͨ͜ͱ • ςετ (PHPUnit, phpspec, behat) • ΧόϨοδ (coveralls) •

    ηΩϡϦςΟ (Sensiolabs Security Advisories Checker) • ґଘؔ܎ (VersionEye) • ϝτϦΫε (phpmd, phpcpd, pdepend) " scrutinizer-ci
  63. CIαʔϏεͷબͼͷϙΠϯτ • ίϯςφͷੑೳͱฒྻʹ࣮ߦՄೳͳδϣϒ਺ " ։ൃεϐʔυʹӨڹ, {։ൃਓ਺} / 10 ͘Β͍ฒߦʹಈ͔͍ͨ͠ •

    ίʔυΛಈ͔͢؀ڥ࡞Γ͕େม͔Ͳ͏͔ " sudo͕ඞཁʁ sshͰϩάΠϯ͍ͨ͠ʁ • OS " RHELܥ࢖͍͔ͨͬͨΒ ʮ Vagrant + EC2 | DigitalOcean ʯ
  64. CIαʔϏεͷબͼͷϙΠϯτ • Amazon Linux΍REHLΛ࢖͍͍ͨ " werkcker + Vagrant + EC2

  65. ͓͢͢Ίͷ૊Έ߹Θͤ • CircleCI • wercker • Travis CI + •

    scrutinizer-ci ςετ ΧόϨοδ ΠϯεϖΫγϣϯ
  66. σϓϩΠ

  67. σϓϩΠπʔϧ • Capistrano • Rocketeer (PHP੡Capistrano) • Magallanes (PHP) •

    Altax (PHP) • envoy (PHP)
  68. CIͱσϓϩΠ • CIͷྲྀΕ 1. લॲཧ (git cloneɺcomposer installͳͲ) 2. ςετ

    3. ޙॲཧ (ΧόϨοδͷੜ੒) 4. σϓϩΠ
  69. ᶃςετ σϓϩΠπʔϧͷ४උ

  70. ᶄ৽͍͠ϦϦʔε༻ͷσΟϨΫτϦΛ࡞੒ SFMFBTFTˡOFX SFMFBTFT DVSSFOUSFMFBTFT

  71. ᶄHJUDMPOF\ϦϙδτϦ^ SFMFBTFTˡOFX

  72. ᶅDPNQPTFSJOTUBMM ࡁ

  73. ᶆᶅΛSTZODѹॖ TDQͳͲͰసૹ SFMFBTFTˡOFX SFMFBTFT DVSSFOUSFMFBTFT

  74. ! ·ͱΊ

  75. ·ͱΊ • ඇಉظͷίϛϡχέʔγϣϯ΋׆༻͠Α͏ • CIαʔϏεͰςετҎ֎ͷ͜ͱ΋৭ʑͰ͖Δ • ༷ʑͳCIαʔϏε͔ΒɺνʔϜʹඞཁͳ΋ͷΛબ΅͏ " ෳ਺ಉ࣌ʹ࢖ͬͯ΋ྑ͍

  76. αϯϓϧ • ։ൃ؀ڥ " https://github.com/ada-u/laravel4-platform ! • ΞϓϦέʔγϣϯ " https://github.com/ada-u/laravel4-sample-

    application
  77. ChatWork ΤϯδχΞɺืूதͰ͢ʂʂ

  78. ͋Γ͕ͱ͏͍͟͝·ͨ͠ɻ