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

CakePHPでも使える Composerを活用したモダンな開発手法

Yusuke Ando
September 14, 2013

CakePHPでも使える Composerを活用したモダンな開発手法

PHPカンファレンス2013にて発表

Yusuke Ando

September 14, 2013
Tweet

More Decks by Yusuke Ando

Other Decks in Programming

Transcript

  1. $PNQPTFSΛ׆༻ͨ͠Ϟμϯͳ։ൃख๏
    $BLF1)1Ͱ΋࢖͑Δ

    View full-size slide

  2. ZBOEP
    $BOEZ$BOFQIQ
    ʮ࠙਌ձϐβൃ஫ΞϓϦʯ

    View full-size slide

  3. 1)1ରԠ1BB4
    $IFGͰ"84Λࣗಈߏங
    $PNQPTFSʹ΋΋ͪΖΜରԠ
    44)TVEPՄೳ͔ͭαϙʔτ༗

    View full-size slide

  4. ΞδΣϯμ
    Կނ$PNQPTFS͕ඞཁ͔ʁ
    ࢖͍ํ
    $BLF1)1ͱ$PNQPTFSͷ૊Έ߹Θͤ

    View full-size slide

  5. $PNQPTFS
    1)1ґଘੑ؅ཧπʔϧ
    DPNQPTFSίϚϯυͰඞཁͳϥΠϒϥ
    ϦΛࣗಈతʹूΊͯ͘ΕΔ
    4ZNGPOZͷػೳͩͬͨ
    ݱࡏ͸σϑΝΫτελϯμʔυ

    View full-size slide

  6. ैདྷͷख๏
    ϥΠϒϥϦ͕ඞཁʹͳΔ
    MJCͱ͔ʹμ΢ϯϩʔυͯ͠ίϐʔ
    ͕Μ͹ͬͯSFRVJSF@PODF

    View full-size slide

  7. ໰୊఺
    Ξοϓσʔτ͕೉͍͠
    ίʔυͷ෼ྔ͕૿͑Δ
    ϥΠϒϥϦ͕͍ͣΕฤू͞ΕΔ
    SFRVJSF@PODF஍ࠈ

    View full-size slide

  8. ͜͏͍͏ͷ͸ྑ͘ͳ͍

    View full-size slide

  9. $PNQPTFSΛ࢖͓͏ʂ

    View full-size slide

  10. ࡞Δ΋ͷ
    7BHSBOUͰಈ͘
    $PNQPTFSͰϥΠϒϥϦΛಋೖ
    5XJUUFS͔Β৘ใऔಘ

    View full-size slide

  11. 7BHSBOU
    7JSUVBM#PY7BHSBOU
    IUUQTHJUIVCDPNZBOEPEQIQ
    OHJOYWBHSBOUTBNQMF
    HJUDMPOF
    WBHSBOUVQ

    View full-size slide

  12. DPNQPTFSKTPO
    WBHSBOUTTI
    DEWBHSBOU@EBUBTBOECPY
    DPNQPTFSKTPOΛهड़͢Δ
    ࣗಈͰ΋खಈͰ΋Ͱ͖Δ

    View full-size slide

  13. DPNQPTFSKTPO
    {
    "name": "llmatsuri/sample",
    "authors": [
    {
    "name": "yando",
    "email": "[email protected]"
    }
    ],
    "require": {
    "dg/twitter-php": "*"
    }
    }

    View full-size slide

  14. DPNQPTFSKTPO
    ΄͍͠ϥΠϒϥϦΛݕࡧͯ͠ࢦఆ͢Δ
    8FCͰ΋ίϚϯυͰ΋ݕࡧͰ͖Δ
    ࣮͸1&"3΋ΠϯετʔϧͰ͖Δ
    ࠷ޙʹDPNQPTFSJOTUBMMͰ·ͱΊͯ%-

    View full-size slide

  15. DPNQPTFSJOTUBMM
    vagrant@precise64:/vagrant_data$ composer install
    Loading composer repositories with package
    information
    Installing dependencies (including require-dev)
    - Installing dg/twitter-php (v3.1)
    Loading from cache
    Writing lock file
    Generating autoload files

    View full-size slide

  16. JOTUBMM͢Δͱ
    DPNQPTFSMPDL͕ੜ੒͞ΕΔ
    WFOEPSҎԼʹϥΠϒϥϦ͕%-͞ΕΔ
    WFOEPSҎԼʹΦʔτϩʔμ͕഑ஔ

    View full-size slide

  17. BVUPMPBE
    BVUPMPBEQIQ͚ͩΛSFRVJSF͢Δ
    ඞཁͳ࣌ʹ֤ΫϥεΛࣗಈͰಡΈࠐΉ
    ೋ౓ͱSFRVJSF@PODFΛॻ͔ͳ͍
    ϑϨʔϜϫʔΫ͕ಡΈࠐΉ৔߹΋͋Δ

    View full-size slide

  18. JOEFYQIQ
    require_once 'vendor/autoload.php';
    $twitter = new Twitter();
    ͜Ε͚ͩͰ5XJUUFSΫϥεΛࣗಈతʹ
    WFOEPSEHUXJUUFSQIQTSD͔ΒಡΈࠐΉʂ

    View full-size slide

  19. Τϥʔʁ
    5XJUUFSΫϥε͸ίϯγϡʔϚΩʔͱ
    ίϯγϡʔϚγʔΫϨοτ͕ඞཁΒ͍͠

    View full-size slide

  20. EFWUXJUUFSDPNBQQT
    αΠϯΞοϓ
    ΞϓϦΛ࡞੒
    ੜ੒͞ΕͨΩʔ৘ใΛίϐͬͯ࢖͏

    View full-size slide

  21. औಘ
    require_once 'vendor/autoload.php';
    $twitter = new Twitter(
    'aaaa',
    'bbbb',
    'cccc',
    'dddd'
    );
    $info = $twitter->loadUserInfo('yando');
    var_dump($info->status->text);

    View full-size slide

  22. ͋ͱ͸
    ϥΠϒϥϦΛDPNQPTFSKTPO΁௥Ճ
    DPNQPTFSVQEBUFͰߋ৽
    WFOEPSΛίϛοτ͠ͳ͍
    σϓϩΠ࣌ʹJOTUBMMͰWFOEPSΛ࠶ੜ

    View full-size slide

  23. ͞Βʹ
    143Λक͍ͬͯΕ͹ࣗ࡞ΫϥεͰ΋
    BVUPMPBEʹରԠͰ͖Δ
    1&"3ͳͲ΋DPNQPTFSͰΠϯετʔϧ
    ࣗ࡞ϥΠϒϥϦ΋QBDLHJTUͰެ։ʂ

    View full-size slide

  24. ࣗ࡞Ϋϥεͷϩʔυ

    View full-size slide

  25. QIQGSJFOET
    HJUIVCDPNZBOEPEQIQGSJFOET
    QIQGSJFOETͷը૾Λऩू
    ࿩ͷ͖͔͚ͬʹ
    ʮQIQGSJFOETͷࣸਅࡱΓ·ͤΜ͔ʁʯ
    SVCZGSJFOETͷύΫϦ

    View full-size slide

  26. ී௨ͷ$BLF
    MJC$BLFͷԼʹϑϨʔϜϫʔΫ
    Ξοϓσʔτ͸ؤுͬͯೖସ͑
    ϦϙδτϦ͕ඒ͘͠ͳ͍

    View full-size slide

  27. DPNQPTFSKTPO

    View full-size slide

  28. ΍Δ͜ͱ
    DPNQPTFSJOTUBMM
    DBLFCBLF
    BQQଆΛࣗಈੜ੒ʂ

    View full-size slide

  29. ࢼ͢ʁ
    7BHSBOUpMF΋ಉ͓͖ࠝͯ͠·ͨ͠
    HJUDMPOF
    WBHSBOUVQ
    IUUQ

    View full-size slide

  30. ·ͱΊ
    $PNQPTFSΛ࢖͏ͱ໘౗ͳ࡞ۀ͕ݮΔ
    ΞοϓσʔτΛසൟʹߦ͍඼࣭޲্
    ରԠ͍ͯ͠Δ1BB4ͰͷεϜʔζͳಈ࡞

    View full-size slide

  31. ࣭໰
    طଘΞϓϦͷ$PNQPTFSҠߦ͸ʁ
    ৽͘͠ಋೖ͢ΔϥΠϒϥϦ͔Βগͮͭ͠Ҡ͠
    ͍ͯ͘ͷͰ΋Α͍ɻ
    ৚݅ʹԠͨ͡ϑϥάͳͲͷઃఆ͸ʁ
    υΩϡϝϯτΛࢀরɻ
    IUUQHFUDPNQPTFSPSHEPD
    TDIFNBNEQBDLBHFMJOLT

    View full-size slide

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

    View full-size slide