Dive into the Cloud with our buddy, lovely PHP!

4584c227ef4ea69e789e5f53e0476418?s=47 omoon
September 28, 2013

Dive into the Cloud with our buddy, lovely PHP!

PHPでクラウドの世界へ飛び込もう。
JAWS FESTA Kansai 2013 でのスライドです。

4584c227ef4ea69e789e5f53e0476418?s=128

omoon

September 28, 2013
Tweet

Transcript

  1. %JWFJOUPUIF$MPVEXJUIPVSCVEEZ  MPWFMZ1)1 ؔ੢1)1ษڧձJO+"84'&45",BOTBJ 4FQUFNCFSUI  4PUBSP0.63" !PNPPO

  2. #jawsfesta "CPVU.F

  3. #jawsfesta "CPVU.F w4PUBSP0.63"

  4. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ

  5. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ w1)1ྺ͸೥΄Ͳʢ࠷ۙ͸'VFM1)1ͱ͔ʣ

  6. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ w1)1ྺ͸೥΄Ͳʢ࠷ۙ͸'VFM1)1ͱ͔ʣ wMPWFOPPEMFT

  7. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ w1)1ྺ͸೥΄Ͳʢ࠷ۙ͸'VFM1)1ͱ͔ʣ wMPWFOPPEMFT wPNPPOPSH

  8. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ w1)1ྺ͸೥΄Ͳʢ࠷ۙ͸'VFM1)1ͱ͔ʣ wMPWFOPPEMFT wPNPPOPSH w!PNPPO

  9. #jawsfesta "CPVU.F w4PUBSP0.63" wגࣜձࣾλοϓ w1)1ྺ͸೥΄Ͳʢ࠷ۙ͸'VFM1)1ͱ͔ʣ wMPWFOPPEMFT wPNPPOPSH w!PNPPO

  10. #jawsfesta ژηϥυʔϜͱฉ͍ͯ

  11. #jawsfesta

  12. #jawsfesta ҆৺͠·ͨ͠

  13. #jawsfesta ࠓ೔࿩͢͜ͱ

  14. #jawsfesta ࠓ೔࿩͢͜ͱ wΫϥ΢υʹ·ͭΘΔݴ༿ͷ੔ཧ

  15. #jawsfesta ࠓ೔࿩͢͜ͱ wΫϥ΢υʹ·ͭΘΔݴ༿ͷ੔ཧ w୅දతΫϥ΢υ঺հ

  16. #jawsfesta ࠓ೔࿩͢͜ͱ wΫϥ΢υʹ·ͭΘΔݴ༿ͷ੔ཧ w୅දతΫϥ΢υ঺հ w࣮ࡍʹΫϥ΢υͰ1)1ΞϓϦέʔγϣϯΛެ։͢Δ৔߹ͷ۩ମతखॱ

  17. #jawsfesta ͱ͜ΖͰ

  18. #jawsfesta "CPVU.F

  19. #jawsfesta "CPVU.F

  20. #jawsfesta

  21. #jawsfesta

  22. #jawsfesta "CPVU.F

  23. #jawsfesta "CPVU.F

  24. #jawsfesta

  25. #jawsfesta Ϋϥ΢υͱ͸

  26. #jawsfesta Ϋϥ΢υͭͷ෼ྨ

  27. #jawsfesta Ϋϥ΢υͭͷ෼ྨ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF

  28. #jawsfesta Ϋϥ΢υͭͷ෼ྨ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF w1BB4 1MBUGPSNBTB4FSWJDF

  29. #jawsfesta Ϋϥ΢υͭͷ෼ྨ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF w1BB4 1MBUGPSNBTB4FSWJDF w4BB4 4PGUXBSFBTB4FSWJDF

  30. #jawsfesta *BB4

  31. #jawsfesta *BB4ʢ͍͋͋ʔ͢ʣ

  32. #jawsfesta *BB4ʢ͍͋ʔ͢ʣ

  33. #jawsfesta *BB4

  34. #jawsfesta *BB4 w"NB[PO8FC4FSWJDFTʢIUUQBXTBNB[PODPNKQʣ

  35. #jawsfesta *BB4 w"NB[PO8FC4FSWJDFTʢIUUQBXTBNB[PODPNKQʣ w͘͞ΒͷΫϥ΢υʢIUUQDMPVETBLVSBBEKQʣ

  36. #jawsfesta *BB4 w"NB[PO8FC4FSWJDFTʢIUUQBXTBNB[PODPNKQʣ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4 w"1*ܦ༝Ͱར༻

  58. #jawsfesta 4BB4 w"1*ܦ༝Ͱར༻ w4%,͕༻ҙ͞Ε͍ͯΔ৔߹͕݁ߏ͋Δ

  59. #jawsfesta

  60. #jawsfesta

  61. #jawsfesta

  62. #jawsfesta

  63. #jawsfesta

  64. #jawsfesta Ϋϥ΢υͭͷ෼ྨͷ͸ͳ͠Ͱͨ͠

  65. #jawsfesta Ϋϥ΢υͭͷ෼ྨͷ͸ͳ͠Ͱͨ͠ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF

  66. #jawsfesta Ϋϥ΢υͭͷ෼ྨͷ͸ͳ͠Ͱͨ͠ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF w1BB4 1MBUGPSNBTB4FSWJDF

  67. #jawsfesta Ϋϥ΢υͭͷ෼ྨͷ͸ͳ͠Ͱͨ͠ w*BB4 *OGSBTUSVDUVSFBTB4FSWJDF w1BB4 1MBUGPSNBTB4FSWJDF w4BB4 4PGUXBSFBTB4FSWJDF

  68. #jawsfesta ͑͑ͷʁΘΔ͍ͷʁ

  69. #jawsfesta ࣌ͱ৔߹ʹΑΔ

  70. #jawsfesta ߟ͑ΒΕΔϝϦοτʢ͔ͳΓେࡶ೺ʣ

  71. #jawsfesta ߟ͑ΒΕΔϝϦοτʢ͔ͳΓେࡶ೺ʣ w͙͢Ͱ͖Δ

  72. #jawsfesta ߟ͑ΒΕΔϝϦοτʢ͔ͳΓେࡶ೺ʣ w͙͢Ͱ͖Δ wͳ͔ͬͨ͜ͱʹͰ͖Δ

  73. #jawsfesta ߟ͑ΒΕΔϝϦοτʢ͔ͳΓେࡶ೺ʣ w͙͢Ͱ͖Δ wͳ͔ͬͨ͜ͱʹͰ͖Δ wίετ

  74. #jawsfesta ߟ͑ΒΕΔσϝϦοτʢ͔ͳΓେࡶ೺ʣ

  75. #jawsfesta ߟ͑ΒΕΔσϝϦοτʢ͔ͳΓେࡶ೺ʣ w࠷ޙͷͱ͜ΖͰ༥௨͕͖͔ͳ͍

  76. #jawsfesta ߟ͑ΒΕΔσϝϦοτʢ͔ͳΓେࡶ೺ʣ w࠷ޙͷͱ͜ΖͰ༥௨͕͖͔ͳ͍ wӳޠʂ

  77. #jawsfesta ߟ͑ΒΕΔσϝϦοτʢ͔ͳΓେࡶ೺ʣ w࠷ޙͷͱ͜ΖͰ༥௨͕͖͔ͳ͍ wӳޠʂ wίετ

  78. #jawsfesta ࣌ͱ৔߹ʹΑΔ

  79. #jawsfesta ·ͣ͸ͨΊͯ͠Έ·͠ΐ͏

  80. #jawsfesta

  81. #jawsfesta

  82. #jawsfesta "CPVU.F

  83. #jawsfesta "CPVU.F

  84. #jawsfesta ͨΊͯ͠ΈΔʹ͋ͨͬͯ

  85. #jawsfesta ஌͓ͬͯ͘΂͖पลٕज़

  86. #jawsfesta TTI

  87. #jawsfesta %  ssh  root@xxx.xxx.xxx.xxx       root@xxx.xxx.xxx.xxx's   password:

  88. #jawsfesta %  ssh  root@xxx.xxx.xxx.xxx       root@xxx.xxx.xxx.xxx's   password:

  89. #jawsfesta TTI

  90. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ

  91. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ wݤͷϖΞΛͭ͘Γ

  92. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ wݤͷϖΞΛͭ͘Γ wͻͱͭ͸ൿີ

  93. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ wݤͷϖΞΛͭ͘Γ wͻͱͭ͸ൿີ wͻͱͭ͸૬खʹ౉͢

  94. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ wݤͷϖΞΛͭ͘Γ wͻͱͭ͸ൿີ wͻͱͭ͸૬खʹ౉͢ w΍ΓͱΓ͢Δͱ͖ʹর߹ͯ͠

  95. #jawsfesta TTI wύεϫʔυ͸࢖Θͣʹ wݤͷϖΞΛͭ͘Γ wͻͱͭ͸ൿີ wͻͱͭ͸૬खʹ౉͢ w΍ΓͱΓ͢Δͱ͖ʹর߹ͯ͠ wΞΫηε͍͍ͯ͠Αʙ

  96. #jawsfesta

  97. #jawsfesta

  98. #jawsfesta

  99. #jawsfesta

  100. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ"84ʣ

  101. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ"84ʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ

  102. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ"84ʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI

  103. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ"84ʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI wαʔόଆͰHJUQVMM

  104. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ"84ʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI wαʔόଆͰHJUQVMM wDPNQPTFSJOTUBMMͳͲ

  105. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ

  106. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ

  107. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wखݩʹHJUDMPOF

  108. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wखݩʹHJUDMPOF w1BHPEB#PYͷϦϙδτϦΛHJUSFNPUFBEE

  109. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wखݩʹHJUDMPOF w1BHPEB#PYͷϦϙδτϦΛHJUSFNPUFBEE wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI

  110. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wखݩʹHJUDMPOF w1BHPEB#PYͷϦϙδτϦΛHJUSFNPUFBEE wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI wαʔόଆʹHJUQVTI

  111. #jawsfesta ίʔυͷσϓϩΠͷ̍Ҋʢ1BHPEB#PYʣ w(JUͷϦϞʔτϦϙδτϦΛ࡞Δ wखݩʹHJUDMPOF w1BHPEB#PYͷϦϙδτϦΛHJUSFNPUFBEE wαʔόͱͷ௨৴͸ΩʔϖΞΛ࢖ͬͨTTI wαʔόଆʹHJUQVTI wDPNQPTFSJOTUBMMͳͲ

  112. #jawsfesta αϯϓϧίʔυ

  113. #jawsfesta αϯϓϧίʔυ wIUUQTHJUIVCDPN1)1&OHJOFFST5SBJOJOH#PPL QIQ@NPPL@TBNQMF

  114. #jawsfesta αϯϓϧίʔυ wIUUQTHJUIVCDPN1)1&OHJOFFST5SBJOJOH#PPL QIQ@NPPL@TBNQMF wσϞ͠·͢

  115. #jawsfesta HJUDMPOF %  git  clone  git@github.com:PHP-­‐Engineers-­‐Training-­‐Book/php_mook_sample.git Cloning  into  'php_mook_sample'... remote:

     Counting  objects:  37,  done. remote:  Compressing  objects:  100%  (33/33),  done. remote:  Total  37  (delta  0),  reused  37  (delta  0) Receiving  objects:  100%  (37/37),  1.02  MiB  |  491  KiB/s,  done.
  116. #jawsfesta

  117. #jawsfesta ▾  php_mook_sample/    ▾  bin/        

       phpmig*  -­‐>  /Users/omoon/Documents/php_mook_sample/vendor/davedevelopment/phpmig/bin/phpmig    ▾  config/            development.php            pagoda.php    ▸  logs/    ▾  migrations/            20130711105053_CreateInitialTables.php*    ▾  public/        ▸  assets/            index.php    ▾  vendor/        ▸  composer/        ▸  davedevelopment/        ▸  doctrine/        ▸  pimple/        ▸  psr/        ▸  silex/        ▸  symfony/        ▸  twig/            autoload.php    ▾  views/            index.twig        Boxfile        composer.json        composer.lock        composer.phar*        phpmig.php
  118. #jawsfesta  1  {  2          "require":  {

     3                  "silex/silex":  "1.*",  4                  "doctrine/dbal":  "2.2.*",  5                  "twig/twig":  "~1.8",  6                  "davedevelopment/phpmig":  "*"  7          },  8          "config":  {  9                  "bin-­‐dir":  "bin/" 10          } 11  }
  119. #jawsfesta DPNQPTFSJOTUBMM  $  curl  -­‐s  http://getcomposer.org/installer  |  php #!/usr/bin/env

     php All  settings  correct  for  using  Composer Downloading... Composer  successfully  installed  to:  /Users/omoon/Documents/php_mook_sample/ composer.phar Use  it:  php  composer.phar
  120. #jawsfesta DPNQPTFSJOTUBMM  %  php  composer.phar  install Loading  composer  repositories

     with  package  information ... ʢུʣ ... symfony/event-­‐dispatcher  suggests  installing  symfony/dependency-­‐injection  () symfony/http-­‐kernel  suggests  installing  symfony/browser-­‐kit  () symfony/http-­‐kernel  suggests  installing  symfony/dependency-­‐injection  () symfony/http-­‐kernel  suggests  installing  symfony/finder  () silex/silex  suggests  installing  symfony/browser-­‐kit  (>=2.3,<2.4-­‐dev) silex/silex  suggests  installing  symfony/css-­‐selector  (>=2.3,<2.4-­‐dev) silex/silex  suggests  installing  symfony/dom-­‐crawler  (>=2.3,<2.4-­‐dev) silex/silex  suggests  installing  symfony/form  (>=2.3,<2.4-­‐dev) Generating  autoload  files
  121. #jawsfesta  1  <?php  2  require  __DIR__  .  '/../vendor/autoload.php';  3  

     4  $app  =  new  Silex\Application();  5    6  $app-­‐>register(new  Silex\Provider\TwigServiceProvider(),  array(  7          'twig.path'  =>  __DIR__.'/../views',  8  ));  9   10  //  σʔλϕʔε઀ଓ৘ใͷಡࠐ 11  $env  =  getenv('APP_ENV')  ?:  'development'; 12  $config  =  require  __DIR__  .  "/../config/$env.php"; 13  $app-­‐>register(new  Silex\Provider\DoctrineServiceProvider(),  array( 14          'db.options'  =>  $config['db'], 15  )); 16   17  //  τοϓը໘ 18  $app-­‐>get('/',  function(Silex\Application  $app)  { 19          $posts  =  $app['db']-­‐>fetchAll(' 20                  SELECT  name,  message,  unix_timestamp(created)  as  created 21                  FROM  posts  ORDER  BY  created  DESC  LIMIT  5 22          '); 23          return  $app['twig']-­‐>render('index.twig',  array( 24                  'posts'  =>  $posts, 25          )); 26  }); 27   28  //  ౤ߘॲཧ 29  $app-­‐>post('/speak',  function(Silex\Application  $app)  { 30          $name  =  $app['request']-­‐>get('name'); 31          $message  =  $app['request']-­‐>get('message'); 32          if  ($name  &&  $message)  { 33                  $app['db']-­‐>insert('posts',  array('name'  =>  $name,  'message'  =>  $message)); 34          } 35          return  $app-­‐>redirect('/'); 36  }); 37   38  $app-­‐>run();
  122. #jawsfesta  1  <?php  2  require  __DIR__  .  '/../vendor/autoload.php';  3  

     4  $app  =  new  Silex\Application();  5    6  $app-­‐>register(new  Silex\Provider\TwigServiceProvider(),  array(  7          'twig.path'  =>  __DIR__.'/../views',  8  ));  9   10  //  σʔλϕʔε઀ଓ৘ใͷಡࠐ 11  $env  =  getenv('APP_ENV')  ?:  'development'; 12  $config  =  require  __DIR__  .  "/../config/$env.php"; 13  $app-­‐>register(new  Silex\Provider\DoctrineServiceProvider(),  array( 14          'db.options'  =>  $config['db'], 15  )); 16   17  //  τοϓը໘ 18  $app-­‐>get('/',  function(Silex\Application  $app)  { 19          $posts  =  $app['db']-­‐>fetchAll(' 20                  SELECT  name,  message,  unix_timestamp(created)  as  created 21                  FROM  posts  ORDER  BY  created  DESC  LIMIT  5 22          '); 23          return  $app['twig']-­‐>render('index.twig',  array( 24                  'posts'  =>  $posts, 25          )); 26  }); 27   28  //  ౤ߘॲཧ 29  $app-­‐>post('/speak',  function(Silex\Application  $app)  { 30          $name  =  $app['request']-­‐>get('name'); 31          $message  =  $app['request']-­‐>get('message'); 32          if  ($name  &&  $message)  { 33                  $app['db']-­‐>insert('posts',  array('name'  =>  $name,  'message'  =>  $message)); 34          } 35          return  $app-­‐>redirect('/'); 36  }); 37   38  $app-­‐>run();
  123. #jawsfesta  1  <?php  2  require  __DIR__  .  '/../vendor/autoload.php';  3  

     4  $app  =  new  Silex\Application();  5    6  $app-­‐>register(new  Silex\Provider\TwigServiceProvider(),  array(  7          'twig.path'  =>  __DIR__.'/../views',  8  ));
  124. #jawsfesta 10  //  σʔλϕʔε઀ଓ৘ใͷಡࠐ 11  $env  =  getenv('APP_ENV')  ?:  'development';

    12  $config  =  require  __DIR__  .  "/../config/$env.php"; 13  $app-­‐>register(new  Silex\Provider\DoctrineServiceProvider(),  array( 14          'db.options'  =>  $config['db'], 15  ));
  125. #jawsfesta 17  //  τοϓը໘ 18  $app-­‐>get('/',  function(Silex\Application  $app)  { 19

             $posts  =  $app['db']-­‐>fetchAll(' 20                  SELECT  name,  message,  unix_timestamp(created)  as  created 21                  FROM  posts  ORDER  BY  created  DESC  LIMIT  5 22          '); 23          return  $app['twig']-­‐>render('index.twig',  array( 24                  'posts'  =>  $posts, 25          )); 26  });
  126. #jawsfesta  1  {  2          "require":  {

     3                  "silex/silex":  "1.*",  4                  "doctrine/dbal":  "2.2.*",  5                  "twig/twig":  "~1.8",  6                  "davedevelopment/phpmig":  "*"  7          },  8          "config":  {  9                  "bin-­‐dir":  "bin/" 10          } 11  }
  127. #jawsfesta 28  //  ౤ߘॲཧ 29  $app-­‐>post('/speak',  function(Silex\Application  $app)  { 30

             $name  =  $app['request']-­‐>get('name'); 31          $message  =  $app['request']-­‐>get('message'); 32          if  ($name  &&  $message)  { 33                  $app['db']-­‐>insert('posts',  array('name'  =>  $name,  'message'  =>  $message)); 34          } 35          return  $app-­‐>redirect('/'); 36  });
  128. #jawsfesta 38  $app-­‐>run();

  129. #jawsfesta ͱʹ͔ͨ͘Ίͯ͠Έ·͠ΐ͏

  130. #jawsfesta ͋Γ͕ͱ͏͍͟͝·ͨ͠