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

PHP で NFC リーダーを実装する 〜 PHP とハードを繋ぐ 〜

memory
PRO
March 28, 2022

PHP で NFC リーダーを実装する 〜 PHP とハードを繋ぐ 〜

English Title: Implementation of an NFC Reader with PHP

memory
PRO

March 28, 2022
Tweet

More Decks by memory

Other Decks in Technology

Transcript

  1. Ί΋Γʔ
    1)1Ͱ/'$ϦʔμʔΛ࣮૷͢Δ

    ʙ1)1ͱϋʔυΛܨ͙ʙ
    1)1FS,BJHJ

    View Slide

  2. @2020 Torana, Inc. @2020 Torana, Inc.
    Ί΋Γʔ
    ࣗݾ঺հ
    1)1Ͱ+7.Λ࣮૷ͨ͠ΓຊΛॻ͍ͯͨΓͯ͠
    ·͢ɻೕ༮ࣇ޲͚஌ҭ؝۩ͷαϒεΫϦϓγϣϯ
    αʔϏεΛఏڙ͢ΔגࣜձࣾτϥʔφͰ$50Λ
    ͍ͯ͠·͢ɻ
    !NNS

    View Slide

  3. @2020 Torana, Inc.
    ΋͘͡
    ΍ͬͯΈΑ͏ͱࢥͬͨϞνϕʔγϣϯ
    /'$Ϧʔμʔͱ͸
    ࣮૷ํ๏
    ·ͱΊ

    View Slide

  4. ΍ͬͯΈΑ͏ͱࢥͬͨ

    Ϟνϕʔγϣϯ

    View Slide

  5. ͭ͋Γ·͢

    View Slide

  6. ܹ͕ࢗཉ͔ͬͨ͠ʜ

    View Slide

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

    View Slide

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

    View Slide

  9. /'$Ϧʔμʔͱ͸

    View Slide

  10. @2020 Torana, Inc.
    /'$Ϧʔμʔͱ͸
    'FMJ$B΍3'*%ͳͲΛ͚ۙͮΔͱɺԿ͔͠Βಈ࡞͢Δ΋ͷɻ
    4VJDB΍1"4.0 F"NVTFNFOU1BTTͳͲ͸'FMJ$B
    ϢχΫϩ΍(6ͳͲʹ͍͍ͭͯΔλά͸3'*%
    ిࢠ֬ఆਃࠂΛ͍ͯ͠Δํ͸ɺ͓ೃછΈ͔΋͠Ε·ͤΜ
    ࠷ۙ4POZ͔Β৽͘͠1B4P3J3$4͕ग़·ͨ͠Ͷ

    View Slide

  11. @2020 Torana, Inc.
    /'$Ϧʔμʔͱ͸
    /'$ʹ͸৭ʑͳن͕֨͋Γ·͢
    جຊతͳن֨͸*40*&$ /'$*1
    *40*&$ /'$*1

    *40*&$ 'FMJ$B ϚΠφϯόʔΧʔυͳͲ

    *40*&$ چF".64&.&/51"44

    *40*&$ ΩϟογϡΧʔυɾΫϨδοτΧʔυ
    ͳͲɻ

    View Slide

  12. @2020 Torana, Inc.
    /'$Ϧʔμʔͱ͸
    /'$ʹ͸৭ʑͳن͕֨͋Γ·͢
    ີணܕ ʙNN
    *40*&$
    ۙ઀ܕ ʙDN
    *40*&$
    ۙ๣ܕ ʙDN
    *40*&$

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  16. ࣮૷ํ๏

    View Slide

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

    View Slide

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

    View Slide

  19. @2020 Torana, Inc.
    ࣮૷ํ๏
    ͦ΋ͦ΋''*ͱ͸
    TP΍EMM EZMJCͱ͍ͬͨڞ༗ϥΠϒϥϦͷ$ͷσʔλߏ଄΍ؔ਺Λ
    ϐϡΞͳ1)1ͰΞΫηεͰ͖ΔΑ͏ʹ͢Δ΋ͷ
    ;FOE&YUFOTJPO"1*΍தؒݴޠΛཧղ͢Δඞཁ͸ಛʹͳ͘ɺ؆қతʹ
    ݺͼग़ͤΔΑ͏ʹͳΔ
    1)1͔Βಋೖ
    ౰࣌͸࢖͍ಓ͋Μ·Γͳ͍Μ͡Όͳ͍͔ɺͱ᷿Ͱ͸࿩୊ʹ

    View Slide

  20. @2020 Torana, Inc.
    ࣮૷ํ๏
    ͦ΋ͦ΋''*ͱ͸
    MJC
    ffi
    ͕ϕʔεʹͳ͍ͬͯ·͢
    IUUQTTPVSDFXBSFPSHMJC
    ffi

    ଞʹ͸3VCZ΍1ZUIPOͳͲʹಋೖ͞Εͯ·͢

    View Slide

  21. ''*ͷαϯϓϧ

    View Slide

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

    View Slide

  23. ࢖ͬͯΔ04ʹΑͬͯมΘΔ͠ɺ

    ྫ͚ͩݟͯ΋ͿͬͪΌ͚Θ͔ΒΜ

    View Slide

  24. ͪͳΈʹ1)1ͷྫ͸NBD04্ͩͱ

    ಈ࡞͠·ͤΜ

    View Slide

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

    View Slide

  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
    ͜ΕΛίʔυʹ૊ΈࠐΉͱʜ

    View Slide

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

    View Slide

  28. ࣮ࡍʹ/'$ϦʔμʔΛ

    ࡞ͬͯΈ·͢

    View Slide

  29. @2020 Torana, Inc.
    ࣮૷ํ๏
    ϋʔυ΢ΣΞଆ͸ҎԼΛ༻ҙ
    1B4P3J3$4
    1B4P3J3$4
    1B4P3J3$4ʹ͍ͭͯ
    NBD04্ͰMJCOGDQDTDMJUFͰಈ͘͜ͱ͸֬ೝͰ͖͍ͯΔͷͰ͕͢ɺ
    ॾ໰୊͕͋ΓࠓճͷτʔΫͰ͸͓ݟૹΓͱ͍͚ͤͯͨͩ͞Ε͹ͱࢥ͍·͢

    View Slide

  30. @2020 Torana, Inc.
    ࣮૷ํ๏
    ιϑτ΢ΣΞଆͷ࣮૷
    MJCOGD·ͨ͸MJCVTC͕࢖͑ΔεΫϦϓτݴޠΛ༻ҙ
    ͭ·Γɺ''*͕࢖͑Ε͹1)1Ͱ΋(PͰ΋3VTUͰ΋࣮૷Ͱ͖·͢

    View Slide

  31. @2020 Torana, Inc.
    ࣮૷ํ๏
    6CVOUV্Ͱ͸ಈ࡞֬ೝ͞ΕͯΔํ͕͍Βͬ
    ͠Ό͍·͢
    IUUQTRJJUBDPNTOJUFNT
    DGBDGBEEC
    NBD04.POUFSFZͩͱͳ͔ͥ6*% /'$*%

    ͕ೝࣝ͞Εͣʜ
    ͦ΋ͦ΋MJCOGDͩͱ'FMJ$B͸ೝࣝ͞Εͳ
    ͍ʢ*40"ͩͱೝࣝ͞ΕΔ໛༷ʣ
    [email protected]ͩͱೝࣝ͞ΕΔ

    View Slide

  32. @2020 Torana, Inc.
    ࣮૷ํ๏
    6CVOUV্Ͱ͸ಈ࡞֬ೝ͞ΕͯΔํ͕͍Βͬ
    ͠Ό͍·͢
    IUUQTRJJUBDPNTOJUFNT
    DGBDGBEEC
    NBD04.POUFSFZͩͱͳ͔ͥ6*% /'$*%

    ͕ೝࣝ͞Εͣʜ
    ͦ΋ͦ΋MJCOGDͩͱ'FMJ$B͸ೝࣝ͞Εͳ
    ͍ʢ*40"ͩͱೝࣝ͞ΕΔ໛༷ʣ
    [email protected]ͩͱೝࣝ͞ΕΔ

    View Slide

  33. @2020 Torana, Inc.
    ࣮૷ํ๏
    ιϑτ΢ΣΞଆͷ࣮૷
    ͨͩ͠MJCOGD͸1B4P3J3$4Ͱ͸ಈ࡞ͤͣ
    ͋ͱ"QQMF8BMMFU΋൓Ԡͤͣ
    ߋʹ1)1''*ʹόά͕͋Γɺ''*ʹΞλον͞ΕΔ΂͖ΦϒδΣΫ
    τ͕Ξλον͞Εͳ͍

    View Slide

  34. @2020 Torana, Inc.
    ࣮૷ํ๏

    View Slide

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

    View Slide

  36. @2020 Torana, Inc.
    ࣮૷ํ๏
    ιϑτ΢ΣΞଆͷ࣮૷
    1B4P3J3$4 1B4P3J3$4Ͱಈ࡞ͤ͞Δ৔߹͸ɺMJCVTCΛ࢖ͬͯ
    ࣗ࡞͢Δඞཁ͕͋Γ·͢
    ͳ͓3$4ͷυΩϡϝϯτ͸ɺ΋͏͢ͰʹखʹೖΒͳ͍໛༷
    1ZUIPOͷOGDQZͰલྫ͕͋ΔͷͰ1)1ʹॻ͖௚͠·ͨ͠
    IUUQTHJUIVCDPNOGDQZOGDQZCMPCNBTUFSTSDOGDDMGSDTQZ

    View Slide

  37. @2020 Torana, Inc.
    ࣮૷ํ๏
    ιϑτ΢ΣΞଆͷ࣮૷
    MJCOGDͰ؆୯ʹ࣮૷͍ͨ͠৔߹͸3$4
    رগՁ஋͕ߴ͘஋ஈ͕ΊͬͪΌߴಅ͍ͯ͠·͕͢ʜ
    MJCVTCͰ൚༻తʹ࣮૷͍ͨ͠৔߹͸3$4

    View Slide

  38. IUUQTHJTUHJUIVCDPN
    NNSDBEEBFBGFBFEEFGDC

    View Slide

  39. MJCOGDͰͷ࣮૷ํ๏

    View Slide

  40. @2020 Torana, Inc.
    MJCOGDͰͷ࣮૷ํ๏
    MJCOGDΛམͱͯ͘͠Δ
    NBDͷ৔߹CSFXJOTUBMMMJCOGD
    VTSMPDBM$FMMBSMJCOGD\όʔδϣϯ^MJCMJCOGDEZMJC͕࢖͑ΔΑ͏
    ʹͳΕ͹0,
    -JOVYͷ৔߹͸VTSMPDBMMJCMJCOGDTP͋ͨΓʹ

    Πϯετʔϧ͞Ε·͢

    View Slide

  41. @2020 Torana, Inc.
    MJCOGDͰͷ࣮૷ํ๏
    MJCOGDʹ͸αϯϓϧ͕͋ΔͷͰɺݟͳ͕Β''*Ͱ࣮૷͕Ͱ͖·͢
    IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPCNBTUFSFYBNQMFT
    OGDQPMMD

    View Slide

  42. @2020 Torana, Inc.
    MJCOGDͰͷ࣮૷ํ๏
    MJCOGDͷαϯϓϧΛಈ͔ͯ͠ΈΔ
    ϋʔυ΢ΣΞΛͭͳ͍ͩঢ়ଶͰ
    VTSMPDBM$FMMBSMJCOGDCJOOGDMJTU
    VTSMPDBM$FMMBSMJCOGDCJOOGDQPMM
    ্هΛ࣮ߦͯ͠ΈΔͱɺαϯϓϧ͕࣮ߦͰ͖·͢

    View Slide

  43. @2020 Torana, Inc.
    MJCOGDͰͷ࣮૷ํ๏
    ''*ʹ࢖༻͢ΔϔομʔϑΝΠϧ
    OGDJOUFSOBMI
    IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPC
    CBEDFCFGCDBBCDCFFCGCFMJCOGDOGDJOUFSOBMI
    OGDUZQFTI
    IUUQTHJUIVCDPNOGDUPPMTMJCOGDCMPC
    CBEDFCFGCDBBCDCFFCGCFJODMVEFOGDOGDUZQFTI

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

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

    View Slide

  48. MJCTVCͰͷ࣮૷ํ๏

    View Slide

  49. @2020 Torana, Inc.
    MJCVTCͰͷ࣮૷ํ๏
    ൚༻తʹ࣮૷͢ΔͳΒMJCVTC
    MJCVTCΛམͱͯ͘͠Δ
    NBDͷ৔߹CSFXJOTUBMMMJCVTC
    VTSMPDBM$FMMBSMJCOGD\όʔδϣϯ^MJCMJCVTCEZMJC͕࢖͑ΔΑ͏ʹͳΕ͹0,
    -JOVYͷ৔߹͸VTSMPDBMMJCMJCVTCTP͋ͨΓʹ

    Πϯετʔϧ͞Ε·͢

    View Slide

  50. @2020 Torana, Inc.
    MJCVTCͰͷ࣮૷ํ๏
    ҎԼΛࢀߟʹ࣮૷
    IUUQTHJUIVCDPNOGDQZOGDQZCMPCNBTUFSTSDOGDDMG
    SDTQZ
    [email protected]
    HFUEFWJDFJEDQQ
    IUUQTRJJUBDPNTBUVSEBZJUFNTGDEGCCDC

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  54. IUUQTHJTUHJUIVCDPNNNS
    EBEFEBFCGDGCE

    View Slide

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

    View Slide

  56. @2020 Torana, Inc.
    MJCVTCͰͷ࣮૷ํ๏
    ൚༻తʹ࣮૷͢ΔͳΒMJCVTC
    MJCVTCΛ࢖͑͹ɺ64#Ͱ઀ଓ͍ͯ͠ΔσόΠεͱ௨৴͕Ͱ͖Δ
    ྫ͑͹ɺ/'$Ҏ֎ʹ΋࢖͍ಓ͸ͨ͘͞Μ͋Δ
    ྫ͑͹εϐʔΧʔɾϔουϑΥϯͱ͔ɺ64#Χϝϥɺ64#ϚΠΫɺ
    64#ΩʔϘʔυɺ64#ϝϞϦ)%%44%ͳͲͱͷ௨৴

    View Slide

  57. %&.0

    View Slide

  58. ·ͱΊ

    View Slide

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

    View Slide

  60. @2020 Torana, Inc.
    ࢀߟ
    IUUQTXXXKJQEFDPSKQBSDIJWFTQVCMJDBUJPOT+ 1%'

    IUUQTXXXTPOZDPKQ1SPEVDUTGFMJDB/'$

    View Slide