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

天高くそびえ立つ巨塔によって PHPをJavaScriptに変換する

天高くそびえ立つ巨塔によって PHPをJavaScriptに変換する

2017.07.15 Potato4d #phpkansai Lightning Talk

Transcript

  1. ఱߴͦ͘ͼཱ͑ͭڊౝʹΑͬͯ PHPΛJavaScriptʹม׵͢Δ 2017.07.15 Potato4d #phpkansai Lightning Talk

  2. ࣗݾ঺հ

  3. @potato4d

  4. None
  5. None
  6. ࿩ͯͨ͠

  7. νϟϥ͍όϯυϚϯΈ͍͔ͨͩ Β΍ΊΖͱݴΘΕΔΞΠίϯͷ ਓ

  8. None
  9. օ͞Μbabel͸͝ଘ஌Ͱ͔͢ʁ

  10. None
  11. ES2015+ͱ͍͏2015೥Ҏ߱ͷ JavaScriptΛݹ͍ES5ʹม׵͢Δ

  12. ESͱ͍͏ͷ͕JavaScriptͷ ϕʔε࢓༷Έ͍ͨͳ΋ͷ

  13. ͦͷޙͷ੢ྐྵ͕ͦͷ࣌ͷ࣌఺Ͱ ͷ࢓༷ʹͳΔ

  14. ৽͍͠JavaScriptͷػೳΛઌʹ ࢼ͢πʔϧ

  15. ݱߦͷJavaScriptͷػೳΛݹ͍ ϒϥ΢βͰಈ͔͢πʔϧ

  16. html5shiv͋Δ͍͸Auto Prefixer

  17. ಥવͰ͕͢͜͜Ͱ

  18. ΫΠζͰ͢ʂ

  19. ES2015͸2015೥ͷJavaScript

  20. ES2016͸2016೥ͷJavaScript

  21. ͡Ό͋ES5͸Կ೥ͷ JavaScriptʁ

  22. ͦ͏Ͱ͢Ͷ

  23. A.D. 5೥Ͱ͢Ͷ

  24. ͜ͷ੢ྐྵ5೥ͷJavaScriptʹม׵ ͢Δπʔϧ

  25. ΍͍ͬͯΔ͜ͱ͸ ೚ҙͷςΩετ to JS

  26. ΍͍ͬͯΔ͜ͱ͸ ೚ҙͷPHP to JS

  27. babel-preset-php

  28. ΍Δ

  29. ͓΋ΉΖʹλʔϛφϧΛ։͘

  30. mkdir _test

  31. cd $_

  32. npm init -

  33. yarn add babel-cli babel- preset-php

  34. > main.php

  35. <?php $hoge=1; var_dump($hoge);

  36. ./node_modules/.bin/babel ./ main.php -o main.js

  37. ΍ͬͨ

  38. ͭΒ͍ͱ͜Ζ

  39. ͍͍ͩͨಈ ͔ͳ͍

  40. file_get_contents΋ಈ͔ͳ͍

  41. xhrʹͳͬͨΓfetchʹͳͬͨΓ͠ͳ ͍

  42. PHP to JSͷເͷπʔϧ

  43. None
  44. ͳ͔ͬͨ

  45. ͓·͚

  46. ࡶʹEC-CUBEΛ Ϗϧυͯ͠ΈΔ