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

PHP で NFC リーダーを実装する

PHP で NFC リーダーを実装する

PHP Conference Okinawa 2022
- Implementation of NFC Reader written in PHP

memory
PRO

August 27, 2022
Tweet

More Decks by memory

Other Decks in Programming

Transcript

  1. Ί΋Γʔ 1)1Ͱ/'$ϦʔμʔΛ࣮૷͢Δ 1)1ΧϯϑΝϨϯεԭೄ

  2. @2020 Torana, Inc. @2020 Torana, Inc. Ί΋Γʔ ࣗݾ঺հ 1)1Ͱ+7.Λ࣮૷ͨ͠ΓຊΛॻ͍ͯͨΓͯ͠ ·͢ɻೕ༮ࣇ޲͚஌ҭ؝۩ͷαϒεΫϦϓγϣϯ

    αʔϏεΛఏڙ͢ΔגࣜձࣾτϥʔφͰ$50Λ ͍ͯ͠·͢ɻ !NNS
  3. @2020 Torana, Inc. ΋͘͡ ΍ͬͯΈΑ͏ͱࢥͬͨϞνϕʔγϣϯ /'$Ϧʔμʔͱ͸ ࣮૷ํ๏ ·ͱΊ

  4. ΍ͬͯΈΑ͏ͱࢥͬͨ 
 Ϟνϕʔγϣϯ

  5. ͭ͋Γ·͢

  6. ܹ͕ࢗཉ͔ͬͨ͠ʜ

  7. εΫϦϓτݴޠͰϋʔυʹܨ͙ܥ͸ 1ZUIPO͹͔Γ࢖ΘΕͯͯζϧ͍ʜ

  8. ͦ͏ͩɺݟฦͯ͠΍Ζ͏

  9. /'$Ϧʔμʔͱ͸

  10. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸  'FMJ$B΍3'*%ͳͲΛ͚ۙͮΔͱɺԿ͔͠Βಈ࡞͢Δ΋ͷɻ  4VJDB΍1"4.0 F"NVTFNFOU1BTTͳͲ͸'FMJ$B 

    ϢχΫϩ΍(6ͳͲʹ͍͍ͭͯΔλά͸3'*%  ిࢠ֬ఆਃࠂΛ͍ͯ͠Δํ͸ɺ͓ೃછΈ͔΋͠Ε·ͤΜ  ࠷ۙ4POZ͔Β৽͘͠1B4P3J3$4͕ग़·ͨ͠Ͷ
  11. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸  /'$ʹ͸৭ʑͳن͕֨͋Γ·͢  جຊతͳن֨͸*40*&$ /'$*1 *40*&$

    /'$*1   *40*&$ 'FMJ$B ϚΠφϯόʔΧʔυͳͲ   *40*&$ چF".64&.&/51"44   *40*&$ ΩϟογϡΧʔυɾΫϨδοτΧʔυ ͳͲɻ
  12. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸  /'$ʹ͸৭ʑͳن͕֨͋Γ·͢  ີணܕ ʙNN *40*&$

     ۙ઀ܕ ʙDN *40*&$  ۙ๣ܕ ʙDN *40*&$
  13. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸

  14. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸

  15. @2020 Torana, Inc. /'$Ϧʔμʔͱ͸  "NB[POΛݟΔͱ৭ΜͳछྨͷΧʔυϦʔμʔ͕͋Γ·͢  ͕ɺࠓճ͸4POZ੡ͷ1B4P3JΛϕʔεʹτʔΫ͠·͢  ࢖༻͢Δϋʔυ΢ΣΞσόΠε

     1B4P3J3$4  1B4P3J3$4
  16. ࣮૷ํ๏

  17. @2020 Torana, Inc. ࣮૷ํ๏ ͦ΋ͦ΋''*ͱ͸ ࢀর: https://www.php.net/manual/ja/intro. ff i .php

  18. ͭ·ΓɺͲ͏͍͏͜ͱͩͬͯ͹Αʁ

  19. @2020 Torana, Inc. ࣮૷ํ๏ ͦ΋ͦ΋''*ͱ͸  TP΍EMM EZMJCͱ͍ͬͨڞ༗ϥΠϒϥϦͷ$ͷσʔλߏ଄΍ؔ਺Λ ϐϡΞͳ1)1ͰΞΫηεͰ͖ΔΑ͏ʹ͢Δ΋ͷ 

    ;FOE&YUFOTJPO"1*΍தؒݴޠΛཧղ͢Δඞཁ͸ಛʹͳ͘ɺ؆қతʹ ݺͼग़ͤΔΑ͏ʹͳΔ  1)1͔Βಋೖ  ౰࣌͸࢖͍ಓ͋Μ·Γͳ͍Μ͡Όͳ͍͔ɺͱ᷿Ͱ͸࿩୊ʹ
  20. @2020 Torana, Inc. ࣮૷ํ๏ ͦ΋ͦ΋''*ͱ͸  MJC ffi ͕ϕʔεʹͳ͍ͬͯ·͢ 

    IUUQTTPVSDFXBSFPSHMJC ffi   ଞʹ͸3VCZ΍1ZUIPOͳͲʹಋೖ͞Εͯ·͢
  21. ''*ͷαϯϓϧ

  22. @2020 Torana, Inc. ࣮૷ํ๏ ''*ͷαϯϓϧ ࢀর: https://www.php.net/manual/ja/ ff i .examples-basic.php

  23. ࢖ͬͯΔ04ʹΑͬͯมΘΔ͠ɺ 
 ྫ͚ͩݟͯ΋ͿͬͪΌ͚Θ͔ΒΜ

  24. ͪͳΈʹ1)1ͷྫ͸NBD04্ͩͱ 
 ಈ࡞͠·ͤΜ

  25. @2020 Torana, Inc. ࣮૷ํ๏ ''*ͷαϯϓϧ ࢀর: https://www.php.net/manual/ja/ ff i .examples-basic.php

    C ͷϔομʔϑΝΠϧʹ͔͔Ε͍ͯΔ΋ͷͩͱࢥ͑͹ OK ݫີʹ͸ɺએݴ͞Ε͍ͯΔ΋ͷ ڞ༗ϥΠϒϥϦ·Ͱͷύε ྫ͸ɺ૬ରύε͕ͩɺઈରύεͰ΋໰୊ͳ͠
  26. @2020 Torana, Inc. ࣮૷ํ๏ ''*ͷαϯϓϧ ࢀর: https://www.php.net/manual/ja/ ff i .examples-basic.php

     NBDͷ৔߹ɺڞ༗ϥΠϒϥϦ͸9$PEFܦ༝ͰΠϯετʔϧ͞ΕΔͷ Ͱɺڞ༗ϥΠϒϥϦͷύε͸ҎԼͰ͢ɻʢࣄલʹ9$PEFͷΠϯετʔ ϧ͕ඞཁʣ  "QQMJDBUJPOT9DPEFBQQ$POUFOUT%FWFMPQFS5PPMDIBJOT 9DPEF%FGBVMUYDUPPMDIBJOVTSMJCMJCDMBOHEZMJC  ͜ΕΛίʔυʹ૊ΈࠐΉͱʜ
  27. @2020 Torana, Inc. ࣮૷ํ๏ ''*ͷαϯϓϧ ࢀর: https://www.php.net/manual/ja/ ff i .examples-basic.php

  28. ࣮ࡍʹ/'$ϦʔμʔΛ 
 ࡞ͬͯΈ·͢

  29. @2020 Torana, Inc. ࣮૷ํ๏  ϋʔυ΢ΣΞଆ͸ҎԼΛ༻ҙ  1B4P3J3$4  1B4P3J3$4

     1B4P3J3$4ʹ͍ͭͯ  NBD04্ͰMJCOGD QDTDMJUFͰಈ͘͜ͱ͸֬ೝͰ͖͍ͯΔͷͰ͕͢ɺ ॾ໰୊͕͋ΓࠓճͷτʔΫͰ͸͓ݟૹΓͱ͍͚ͤͯͨͩ͞Ε͹ͱࢥ͍·͢
  30. @2020 Torana, Inc. ࣮૷ํ๏  ιϑτ΢ΣΞଆͷ࣮૷  MJCOGD·ͨ͸MJCVTC͕࢖͑ΔεΫϦϓτݴޠΛ༻ҙ  ͭ·Γɺ''*͕࢖͑Ε͹1)1Ͱ΋(PͰ΋3VTUͰ΋࣮૷Ͱ͖·͢

  31. @2020 Torana, Inc. ࣮૷ํ๏  6CVOUV্Ͱ͸ಈ࡞֬ೝ͞ΕͯΔํ͕͍Βͬ ͠Ό͍·͢  IUUQTRJJUBDPNTOJUFNT DGBDGBEEC

     NBD04.POUFSFZͩͱͳ͔ͥ6*% /'$*%  ͕ೝࣝ͞Εͣʜ  ͦ΋ͦ΋MJCOGDͩͱ'FMJ$B͸ೝࣝ͞Εͳ ͍ʢ*40"ͩͱೝࣝ͞ΕΔ໛༷ʣ  QDTD@TDBOͩͱೝࣝ͞ΕΔ
  32. @2020 Torana, Inc. ࣮૷ํ๏  6CVOUV্Ͱ͸ಈ࡞֬ೝ͞ΕͯΔํ͕͍Βͬ ͠Ό͍·͢  IUUQTRJJUBDPNTOJUFNT DGBDGBEEC

     NBD04.POUFSFZͩͱͳ͔ͥ6*% /'$*%  ͕ೝࣝ͞Εͣʜ  ͦ΋ͦ΋MJCOGDͩͱ'FMJ$B͸ೝࣝ͞Εͳ ͍ʢ*40"ͩͱೝࣝ͞ΕΔ໛༷ʣ  QDTD@TDBOͩͱೝࣝ͞ΕΔ
  33. @2020 Torana, Inc. ࣮૷ํ๏  ιϑτ΢ΣΞଆͷ࣮૷  ͨͩ͠MJCOGD͸1B4P3J3$4Ͱ͸ಈ࡞ͤͣ  ͋ͱ"QQMF8BMMFU΋൓Ԡͤͣ

     ߋʹ1)1''*ʹόά͕͋Γɺ''*ʹΞλον͞ΕΔ΂͖ΦϒδΣΫ τ͕Ξλον͞Εͳ͍
  34. @2020 Torana, Inc. ࣮૷ํ๏

  35. 1)1''*ͷόά౿Μͩʜ

  36. @2020 Torana, Inc. ࣮૷ํ๏  ιϑτ΢ΣΞଆͷ࣮૷  1B4P3J3$4 1B4P3J3$4Ͱಈ࡞ͤ͞Δ৔߹͸ɺMJCVTCΛ࢖ͬͯ ࣗ࡞͢Δඞཁ͕͋Γ·͢

     ͳ͓3$4ͷυΩϡϝϯτ͸ɺ΋͏͢ͰʹखʹೖΒͳ͍໛༷  1ZUIPOͷOGDQZͰલྫ͕͋ΔͷͰ1)1ʹॻ͖௚͠·ͨ͠  IUUQTHJUIVCDPNOGDQZOGDQZCMPCNBTUFSTSDOGDDMGSDTQZ
  37. @2020 Torana, Inc. ࣮૷ํ๏  ιϑτ΢ΣΞଆͷ࣮૷  MJCOGDͰ؆୯ʹ࣮૷͍ͨ͠৔߹͸3$4  رগՁ஋͕ߴ͘஋ஈ͕ΊͬͪΌߴಅ͍ͯ͠·͕͢ʜ

     MJCVTCͰ൚༻తʹ࣮૷͍ͨ͠৔߹͸3$4
  38. IUUQTHJTUHJUIVCDPN NNSDBEEBFBGFBFEEFGDC

  39. MJCOGDͰͷ࣮૷ํ๏

  40. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  MJCOGDΛམͱͯ͘͠Δ  NBDͷ৔߹CSFXJOTUBMMMJCOGD  

    CSFXQSF fi Y $FMMBSMJCOGD\όʔδϣϯ^MJCMJCOGDEZMJC͕࢖͑ ΔΑ͏ʹͳΕ͹0,  -JOVYͷ৔߹͸VTSMPDBMMJCMJCOGDTP͋ͨΓʹ 
 Πϯετʔϧ͞Ε·͢
  41. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  MJCOGDʹ͸αϯϓϧ͕͋ΔͷͰɺݟͳ͕Β''*Ͱ࣮૷͕Ͱ͖·͢  IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPCNBTUFSFYBNQMFT OGDQPMMD

  42. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  MJCOGDͷαϯϓϧΛಈ͔ͯ͠ΈΔ  ϋʔυ΢ΣΞΛͭͳ͍ͩঢ়ଶͰ  

    CSFXQSF fi Y $FMMBSMJCOGDCJOOGDMJTU   CSFXQSF fi Y $FMMBSMJCOGDCJOOGDQPMM ্هΛ࣮ߦͯ͠ΈΔͱɺαϯϓϧ͕࣮ߦͰ͖·͢
  43. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  ''*ʹ࢖༻͢ΔϔομʔϑΝΠϧ  OGDJOUFSOBMI  IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPC

    CBEDFCFGCDBBCDCFFCGCFMJCOGDOGDJOUFSOBMI  OGDUZQFTI  IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPC CBEDFCFGCDBBCDCFFCGCFJODMVEFOGDOGDUZQFTI
  44. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏

  45. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  ϔομʔϑΝΠϧͷத਎Λॻ͍͍ͯ͘ͱɺҎԼͷΑ͏ʹΞΫηε͕Ͱ͖ ΔΑ͏ʹͳΓ·͢

  46. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏

  47. @2020 Torana, Inc. MJCOGDͰͷ࣮૷ํ๏  ͪͳΈʹɺϔομʔϑΝΠϧ͸1)1ͷ''* Ͱ͸ఆ਺΍ϚΫϩɺؔ਺ͳͲͷఆٛ͸Ͱ͖ͳ ͍ͷͰखॻ͖Ͱमਖ਼·ͨ͸࡟আͷඞཁ͕ 
 ͋Γ·͢

     ࠨਤͷΑ͏ͳίʔυ͸࡟আ͢Δඞཁ͕͋Γ· ͢ɻ  ͦͷͨΊɺ࢒೦ͳ͕ΒҰ෦ͷίʔυ͸ಈ͔ͳ ͔ͬͨΓ͠·͢
  48. MJCTVCͰͷ࣮૷ํ๏

  49. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  ൚༻తʹ࣮૷͢ΔͳΒMJCVTC  MJCVTCΛམͱͯ͘͠Δ  NBDͷ৔߹CSFXJOTUBMMMJCVTC

      CSFXQSF fi Y $FMMBSMJCOGD\όʔδϣϯ^MJCMJCVTCEZMJC͕࢖͑ΔΑ͏ʹͳΕ͹ 0,  -JOVYͷ৔߹͸VTSMPDBMMJCMJCVTCTP͋ͨΓʹ 
 Πϯετʔϧ͞Ε·͢
  50. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  ҎԼΛࢀߟʹ࣮૷  IUUQTHJUIVCDPNOGDQZOGDQZCMPCNBTUFSTSDOGDDMG SDTQZ 

    IUUQTHJUIVCDPNZTPNFJUFTU@HFUOGDJECMPCNBTUFS HFUEFWJDFJEDQQ  IUUQTRJJUBDPNTBUVSEBZJUFNTGDEGCCDC
  51. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  ''*ʹ࢖༻͢ΔϔομʔϑΝΠϧ  IUUQTHJUIVCDPNMJCVTCMJCVTCCMPCNBTUFSMJCVTCMJCVTCI

  52. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  ͦ΋ͦ΋64#Ͱ઀ଓ͞Ε͍ͯΔ΋ͷΛҰཡͰදࣔ͢Δʹ͸  NBDͩͱCSFXJOTUBMMMTVTCΛೖΕΔͱखܰʹ֬ೝͰ͖·͢

  53. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  MJCVTCͰ/'$ϦʔμʔΛ࡞Δલʹɺख࢝ΊʹσόΠεͷҰཡΛऔಘ ͢ΔίʔυΛॻ͍ͯΈΔͷ͕͍͍͔ͳͱࢥ͍·͢  ҎԼΛࢀߟʹ 

    IUUQTHJUIVCDPNMJCVTCMJCVTCCMPCNBTUFSFYBNQMFT MJTUEFWTD
  54. IUUQTHJTUHJUIVCDPNNNS EBEFEBFCGDGCE

  55. IUUQTHJUIVCDPNNNSOGDGPSQIQCMPC NBTUFSTSD%SJWFST3$43$4$PNNBOEQIQ

  56. @2020 Torana, Inc. MJCVTCͰͷ࣮૷ํ๏  ൚༻తʹ࣮૷͢ΔͳΒMJCVTC  MJCVTCΛ࢖͑͹ɺ64#Ͱ઀ଓ͍ͯ͠ΔσόΠεͱ௨৴͕Ͱ͖Δ  ྫ͑͹ɺ/'$Ҏ֎ʹ΋࢖͍ಓ͸ͨ͘͞Μ͋Δ

     ྫ͑͹εϐʔΧʔɾϔουϑΥϯͱ͔ɺ64#Χϝϥɺ64#ϚΠΫɺ 64#ΩʔϘʔυɺ64#ϝϞϦ)%%44%ͳͲͱͷ௨৴
  57. %&.0

  58. ·ͱΊ

  59. @2020 Torana, Inc. ·ͱΊ  ϋʔυ΢ΣΞ͕བྷΜͰ͘Δͱϋʔυϧ͕ΊͬͪΌ্͕Δؾ͕͠·͕͢ɺ ҙ֎ͱ؆୯ʹ࣮૷͕Ͱ͖·͢  ࣍͸1)1Ͱ#MVFUPPUI΍Γ͍ͨͳͱࢥͬͯ·͢ 

    ඇಉظॲཧͱ͍͍1)1ͰͳΜͰ΋Ͱ͖Δ࣌୅ʹͳ͖ͬͯͨͳͱࢥͬͯ ·͢
  60. @2020 Torana, Inc. ࢀߟ  IUUQTXXXKJQEFDPSKQBSDIJWFTQVCMJDBUJPOT+ 1%'   IUUQTXXXTPOZDPKQ1SPEVDUTGFMJDB/'$