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

Composerプラグインを作ってみよう /phpcon2016

Hiraku NAKANO
November 03, 2016

Composerプラグインを作ってみよう /phpcon2016

PHPカンファレンス2016 トラック1 の発表資料です。

Hiraku NAKANO

November 03, 2016
Tweet

More Decks by Hiraku NAKANO

Other Decks in Technology

Transcript

  1. composerϓϥάΠϯΛ

    ࡞ͬͯΈΑ͏
    PHPΧϯϑΝϨϯε2016
    τϥοΫ1

    View full-size slide

  2. ࣗݾ঺հ
    • த໺ ୓ (@Hiraku)
    • https://github.com/hirak
    • ීஈ͸ϝϧΧϦͰαʔόʔαΠυΤϯδχΞ

    ΍ͬͯ·͢
    • झຯ͸ComposerΛ଎͘͢Δ͜ͱ

    View full-size slide

  3. hirak/prestissimo
    • ͱ͍͏ComposerϓϥάΠϯΛ࡞͍ͬͯ·͢
    • githubͰ2000starήοτ͠·ͨ͠

    View full-size slide

  4. Composerͱ͸Կ͔ʁ

    View full-size slide

  5. Composerͱ͸
    • PHPϥΠϒϥϦͷґଘؔ܎ղܾπʔϧ
    • 2011ࠒʹ։ൃελʔτ / PHP5.3Ҏ߱ʹରԠ
    • autoloaderͷࣗಈੜ੒
    • ଟ༷ͳϦϙδτϦܗࣜʹରԠ
    • ϓϥάΠϯػߏ
    • https://getcomposer.org/

    View full-size slide

  6. ࢖͍͸͡ΊΔͷ͸؆୯
    https://getcomposer.org/download/
    pharϑΝΠϧΛҰݸμ΢ϯϩʔυ͢Δ͚ͩɻ

    installerܦ༝Λਪ঑ʢϋογϡ஋ͷݕূʣ
    $ curl -sL https://getcomposer.org/installer | php
    (実態はこんな感じ)
    $ curl -O composer https://getcomposer.org/download/1.1.3/composer.phar

    View full-size slide

  7. $ composer
    ______
    / ____/___ ____ ___ ____ ____ ________ _____
    / / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
    / /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
    \____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
    /_/
    Composer version 1.1.2 2016-05-31 19:48:11
    Usage:
    command [options] [arguments]
    Options:
    -h, --help Display this help message
    -q, --quiet Do not output any message
    -V, --version Display this application version
    --ansi Force ANSI output
    --no-ansi Disable ANSI output
    -n, --no-interaction Do not ask any interactive question
    --profile Display timing and memory usage information
    --no-plugins Whether to disable plugins.
    -d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
    -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2
    for more verbose output and 3 for debug

    View full-size slide

  8. Α͘࢖͏αϒίϚϯυ
    対話形式でプロジェクトをセットアップ
    $ composer init
    ライブラリの追加
    $ composer require 'vendor/package'
    ライブラリのアップデート
    $ composer update
    composer.jsonに従ってまとめてインストール
    $ composer install

    View full-size slide

  9. શͯΛϩʔΧϧʹΠϯετʔϧ
    • ./composer.json
    • ඞཁͳϥΠϒϥϦΛఆٛ
    • ޙ͸ composer install
    • ./vendor/ ʹϥΠϒϥϦͱ autoload.php ͕
    ഑ஔ͞ΕΔ

    View full-size slide

  10. ࠷ۙͷComposer
    • 4/5ʹॳͷstable൛1.0.0ϦϦʔε

    (ຊൃද࣌఺ͷ࠷৽͸ 1.2.1)
    • pathϦϙδτϦͷରԠڧԽ
    • ϓϥάΠϯͰαϒίϚϯυੜ΍ͤΔΑ͏ʹ
    • ࡞ऀͷJordi Boggiano͕7݄ʹདྷ೔

    View full-size slide

  11. ࣭໰ʮPHPҎ֎ͷݴޠͰComposer
    Λ࣮૷͢ΔΞΠσΞ͸Ͳ͏ࢥ͏ʁʯ
    • ࠓͷComposer͸͋·Γ଎͘ͳ͍
    • ྫ͑͹ฒྻॲཧʹڧ͍ݴޠͰ࣮૷͢Ε͹΋ͬ
    ͱߴ଎ʹͰ͖ΔͷͰ͸…

    View full-size slide

  12. @seldaek
    PHPͰॻ͍ͯ͋Δ͔Βͦ͜ɺ

    PHPͰ֦ுͰ͖ΔΑ͏ʹͳͬͯΔ

    View full-size slide

  13. ComposerΛ֦ு͢Δɺͱ͸

    View full-size slide

  14. ֦ுͯ͠Ͱ͖Δ͜ͱ
    • composerίϚϯυͷલޙͰ೚ҙͷॲཧΛ࣮ߦ

    (ΠϕϯτϑοΫܕ)
    • αϒίϚϯυΛComposerʹੜ΍͢

    (αϒίϚϯυܕ)

    View full-size slide

  15. ComposerϓϥάΠϯͰͷྫ

    View full-size slide

  16. $ composer global require
    hirak/prestissimo

    View full-size slide

  17. hirak/prestissimo (੿࡞)
    • ΠϕϯτϑοΫܕ
    • composerຊମͷμ΢ϯϩʔυʹׂΓࠐΜͰɺ
    ઌʹฒྻμ΢ϯϩʔυ͢Δ͜ͱͰinstallίϚϯ
    υΛߴ଎Խ
    • ͦͷଞ͸طଘίϚϯυʹӨڹΛ༩͑ͳ͍

    View full-size slide

  18. ͲΕ͙Β͍଎͘ͳΔͷ͔
    • ύοέʔδͱωοτϫʔΫ؀ڥʹΑΔͷͰҰ
    ֓ʹݴ͑ͳ͍
    • LaravelϓϩδΣΫτͷ৽ن࡞੒ͩͱɺ
    • 269.36sec → 24.32sec
    • 10ഒҎ্଎͍

    View full-size slide

  19. $ composer global require
    fxp/composer-asset-plugin

    View full-size slide

  20. fxp/composer-asset-plugin
    • ΠϕϯτϑοΫܕ
    • composer.jsonʹbower΍npmͷύοέʔδ
    Λॻ͍ͯɺcomposerଆͰΠϯετʔϧͰ͖Δ
    Α͏ʹ͢Δ
    • ΁ɺมଶͩʔʔʔʂʂʂʢ๙Ίݴ༿ʣ

    View full-size slide

  21. composer.json͕͜͏ͳΔ
    "require": {
    "fxp/composer-asset-plugin": "^1.2",
    "npm-asset/jquery": "2.2.0",
    "npm-asset/bootstrap": "3.3.7"
    }
    • npm-asset/xxxx͸packagistʹొ࿥͞Ε͍ͯͳ͍ɻ

    npmΛΫϩʔϧͯ͠औͬͯ͘Δ
    • vendor/npm-asset ΍ vendor/bower-asset ΁഑ஔ͞ΕΔ
    • node.jsͳ͠Ͱasset؅ཧ͕Ͱ͖ͯศརʂ

    View full-size slide

  22. $ composer global require
    webysther/composer-
    plugin-qa

    View full-size slide

  23. webysther/composer-plugin-qa
    • αϒίϚϯυܕ
    • vendor/bin/XXXXͳ։ൃ༻ίϚϯυΛ
    composerͷαϒίϚϯυͰ࣮ߦͰ͖ΔΑ͏ʹ
    ͢Δ

    View full-size slide

  24. vendor/bin/phpunit

    ͬͯଧͭͷμα͍໰୊
    • phpunit͸ϩʔΧϧΠϯετʔϧ͢Δ΂͖
    • ͔͠͠PATH͕௨ͬͯͳ࣮ͯ͘ߦ͕໘౗
    • composerͷαϒίϚϯυܦ༝Ͱݺ΂Δͱศར
    • composer qa:test Ͱphpunit͕࣮ߦ͞Εͯ

    ศར

    View full-size slide

  25. ༗໊ͳͷ΄ͱΜͲೖͬͯΔ

    View full-size slide

  26. ͳͥɺComposerΛ

    ֦ு࣮ͯ͠ݱ͢Δͷ͔ʁ

    View full-size slide

  27. composer͕஌͍ͬͯΔ΋ͷ
    • ϓϩδΣΫτͷϝλ৘ใ
    • Ͳ͜ʹͲͷΫϥεϑΝΠϧ͕͋Δ͔
    • ϓϩδΣΫτຊମͷιʔείʔυΛࣗ༝ʹݺ
    ͼग़ͤΔ

    View full-size slide

  28. composer͕͍࣋ͬͯΔ΋ͷ
    • symfony/console΍symfony/finderͳͲͷఆ൪
    ίϚϯυϥΠϯϥΠϒϥϦΛ࠷ॳ͔Βಉࠝ
    • ѹ౗తͳϢʔβʔ਺ʹཪଧͪ͞ΕͨҠ২ੑ
    • ͍ͭͰʹɺϓϥάΠϯͷܗʹ͓͚ͯ͠͹഑෍΋
    ָ͍͢͝

    View full-size slide

  29. (prestissimo͸ϓϥάΠϯͱ
    ͯ͠͸अಓͳྫ)

    View full-size slide

  30. ϓϥάΠϯҎલͷ֦ுํ๏

    View full-size slide

  31. scriptsͱ͸
    • composer.jsonʹscriptsͱ͍͏ϓϩύςΟΛ࡞Δ
    • ೚ҙͷεΫϦϓτΛ࣮ߦͰ͖Δ
    • ΠϕϯτϑοΫͰࣗಈ࣮ߦ / खಈ࣮ߦ
    • ରԠ͢ΔΠϕϯτ͕ͳ͚Ε͹ɺcomposerͷαϒίϚϯυ
    ʹͳΔ
    • https://getcomposer.org/doc/articles/scripts.md

    View full-size slide

  32. ͍͍ͩͨ͜Μͳײ͡
    {
    "scripts": {
    "test": "phpunit",
    "postinstall": "rm -rf ./cache",
    "migrate": "App\Db\Migration::run"
    }
    }
    WFOEPSCJOʹ1"5)
    ͕௨ͬͯΔͷͰݺ΂Δ
    γΣϧεΫϦϓτͰ΋
    0,
    BVUPMPBE͕௨ͬͯΕ͹1)1ͷ
    TUBUJDϝιουͰ΋ॻ͚Δ

    View full-size slide

  33. ݺͼग़͠
    $ composer test
    $ composer migrate
    $ composer install # postinstallが自動発動
    $ composer run postinstall # 明示発動

    View full-size slide

  34. scriptsͩͱਏ͍ͱ͜Ζ
    • ଞͷcomposerϓϩδΣΫτͰ΋࢖͍·Θͨ͠
    ͍ͳΒɺcomposer.jsonΛίϐϖ͢Δ͔͠ͳ͍
    • ϓϥάΠϯԽ͓ͯ͘͠ͱɺrequire͢Δ͚ͩͰ
    ࢖͍·ΘͤΔΑ͏ʹͳΔ

    View full-size slide

  35. ComposerϓϥάΠϯ
    ύοέʔδԽͨ͠scripts
    ʹ

    View full-size slide

  36. ComposerϓϥάΠϯΛ࡞Δ

    View full-size slide

  37. ComposerϓϥάΠϯͷ࡞Γํ
    • https://getcomposer.org/doc/articles/
    plugins.md
    • ͪΐͬͱ࡞๏͕͋Δ͚ͩͰɺ࡞Δ΋ͷ͸ී௨
    ͷcomposerϥΠϒϥϦͱಉ͡

    View full-size slide

  38. ༻ҙ͢Δ΋ͷ
    • composer.pharͱͦΕ͕ಈ͘؀ڥ
    • composerͷιʔείʔυ
    • ͖͋ΒΊͳ͍৺ʢॏཁʣ

    View full-size slide

  39. େମͷྲྀΕ
    ࡞Ζ͏ͱ͍ͯ͠Δ
    QMVHJOύοέʔδ
    ࣮ݧ୆ͷ
    DPNQPTFSύοέʔδ
    ιʔείʔυ൛
    DPNQPTFS
    pathͰrequireͤ͞Δ
    ࣮ࡍʹૢ࡞

    ͯ͠ಈ࡞֬ೝ
    ಈ͔ͳ͔ͬͨΒ

    मਖ਼

    View full-size slide

  40. େମͷྲྀΕ
    ࡞Ζ͏ͱ͍ͯ͠Δ
    QMVHJOύοέʔδ
    ࣮ݧ୆ͷ
    DPNQPTFSύοέʔδ
    ιʔείʔυ൛
    DPNQPTFS
    pathͰrequireͤ͞Δ
    ࣮ࡍʹૢ࡞

    ͯ͠ಈ࡞֬ೝ
    ಈ͔ͳ͔ͬͨΒ

    मਖ਼

    View full-size slide

  41. ιʔείʔυ൛composer

    ͷεεϝ
    • ޷͖ͳ͚ͩvar_dumpσόοάͰ͖Δ
    • ελοΫτϨʔε΋ಡΈ΍͘͢ͳΔ
    • ࠷ޙ͸ιʔείʔυΛಡ·͟ΔΛಘͳ͍෦෼
    ͕ଟ͍

    View full-size slide

  42. ιʔείʔυͷ··composer
    Λಈ͔͢
    $ git clone git://github.com/composer/composer.git
    $ cd composer
    $ php path/to/composer.phar install --no-dev
    $ bin/composer --version
    Composer version @package_branch_alias_version@ (@package_version@)
    @release_date@

    View full-size slide

  43. ιʔείʔυͷ··composer
    Λಈ͔͢
    $ git clone git://github.com/composer/composer.git
    $ cd composer
    $ php path/to/composer.phar install --no-dev
    $ bin/composer --version
    Composer version @package_branch_alias_version@ (@package_version@)
    @release_date@

    View full-size slide

  44. composer.pharΛϏϧυ͢Δʹ͸
    composer.phar͕ඞཁ
    • ʮ෰Λങ͍ʹߦ͘෰͕ͳ͍ʯΈ͍ͨͳ

    ηϧϑϗεςΟϯάঢ়ଶ
    • ڀۃͷυοάϑʔσΟϯάମ੍

    View full-size slide

  45. େମͷྲྀΕ
    ࡞Ζ͏ͱ͍ͯ͠Δ
    QMVHJOύοέʔδ
    ࣮ݧ୆ͷ
    DPNQPTFSύοέʔδ
    ιʔείʔυ൛
    DPNQPTFS
    pathͰrequireͤ͞Δ
    ࣮ࡍʹૢ࡞

    ͯ͠ಈ࡞֬ೝ
    ಈ͔ͳ͔ͬͨΒ

    मਖ਼

    View full-size slide

  46. ϓϥάΠϯͷcomposerϓϩ
    δΣΫτΛ࡞Δ
    • $ composer init
    • type Λ composer-plugin ʹ͢Δ
    • require ʹ composer-plugin-api ΛೖΕΔɻ࠷৽൛^1.0Ͱྑ͍
    • Ϣχοτςετ΋ॻ͖͍ͨͳΒɺrequire-devʹ"composer/
    composer"ΛՃ͑Δ
    • extra.classʹىಈΫϥε໊Λొ࿥

    View full-size slide

  47. composer.jsonͷྫ
    {
    "name": "my/plugin-package",
    "type": "composer-plugin",
    "require": {
    "composer-plugin-api": "^1.0"
    },
    "require-dev": {
    "composer/composer": "1.2.0",
    "phpunit/phpunit": "^5.3"
    },
    "autoload": {
    "psr-4": {"My\\": "src/"}
    },
    "extra": {
    "class": "My\\Plugin"
    }
    }

    View full-size slide

  48. େମͷྲྀΕ
    ࡞Ζ͏ͱ͍ͯ͠Δ
    QMVHJOύοέʔδ
    ࣮ݧ୆ͷ
    DPNQPTFSύοέʔδ
    ιʔείʔυ൛
    DPNQPTFS
    pathͰrequireͤ͞Δ
    ࣮ࡍʹૢ࡞

    ͯ͠ಈ࡞֬ೝ
    ಈ͔ͳ͔ͬͨΒ

    मਖ਼

    View full-size slide

  49. ࣮ݧ୆ͷcomposerϓϩδΣΫ
    τΛ࡞Δ
    • ద౰ͳύεͰcomposer init͢Δ
    • த਎͸ۭͬΆͰ΋ϑϨʔϜϫʔΫΠϯετʔ
    ϧঢ়ଶͰ΋ͳΜͰ΋ྑ͍
    • ϓϥάΠϯΛ࣮ࡍʹ࢖͏৔໘Λ૝ఆ

    View full-size slide

  50. pathͰpluginΛrequire͢Δ
    {
    "name": "my/somepj",
    "type": "library",
    "repositories": [
    {
    "type": "path",
    "url": "../plugin-package"
    }
    ],
    "require": {
    "my/plugin-package": "@dev"
    }
    }

    View full-size slide

  51. pathϦϙδτϦͷಛੑ
    • ͨͩͷγϯϘϦοΫϦϯΫΛுΔ͚ͩ
    • ͳͷͰߋ৽͕ϦΞϧλΠϜʹ൓ө͞ΕΔ
    • όʔδϣϯ؅ཧ͸ແཧͳͷͰ"@dev"Λࢦఆ

    View full-size slide

  52. ޙ͸ͻͨ͢Βࢼߦࡨޡ

    View full-size slide

  53. namespace My;
    use Composer\Composer;
    use Composer\IO\IOInterface;
    use Composer\Plugin\PluginInterface;
    class Plugin implements PluginInterface
    {
    private $composer;
    private $io;
    public function activate(Composer $composer, IOInterface $io)
    {
    $this->composer = $composer;
    $this->io = $io;
    }
    }
    جຊܕ

    View full-size slide

  54. namespace My;
    use Composer\Composer;
    use Composer\IO\IOInterface;
    use Composer\Plugin\PluginInterface;
    use Composer\EventDispatcher\EventSubscriberInterface;
    use Composer\EventDispatcher\Event;
    class Plugin implements PluginInterface, EventSubscriberInterface
    {
    private $composer;
    private $io;
    public function activate(Composer $composer, IOInterface $io)
    {
    $this->composer = $composer;
    $this->io = $io;
    }
    public static function getSubscribedEvents()
    {
    return array(
    'post-autoload-dump' => 'onPostAutoloadDump',
    );
    }
    public function onPostAutoloadDump(Event $ev)
    {
    $this->io->write('onPostAutoloadDump');
    }
    }
    Πϕϯτϋϯυϥܕ
    ΠϯλʔϑΣʔεΛҰͭ௥Ճ
    ϑοΫ͢ΔΠϕϯτΛྻڍ
    ࣮ߦ͞ΕΔॲཧͷຊମ

    View full-size slide

  55. namespace My;
    use Composer\Composer;
    use Composer\IO\IOInterface;
    use Composer\Plugin\PluginInterface;
    use Composer\Plugin\Capable;
    class Plugin implements PluginInterface, Capable
    {
    private $composer;
    private $info;
    public function activate(Composer $composer, IOInterface $io)
    {
    $this->composer = $composer;
    $this->io = $io;
    }
    public function getCapabilities()
    {
    return array(
    'Composer\Plugin\Capability\CommandProvider' => 'My\Commands',
    );
    }
    }
    αϒίϚϯυܕ
    ΠϯλʔϑΣʔεΛҰͭ௥Ճ
    $PNNBOEҰཡΛ

    ද͢ΫϥεΛઃఆ

    View full-size slide

  56. namespace My;
    use Composer\Plugin\Capability\CommandProvider;
    class Commands implements CommandProvider
    {
    public function getCommands()
    {
    return array(
    new HelloCommand
    );
    }
    }
    αϒίϚϯυܕ(2)
    ഑ྻͰίϚϯυΛ

    ྻڍ

    View full-size slide

  57. namespace My;
    use Composer\Command\BaseCommand;
    use Symfony\Component\Console\Input\InputInterface;
    use Symfony\Component\Console\Output\OutputInterface;
    class HelloCommand extends BaseCommand
    {
    protected function configure()
    {
    $this->setName('hello');
    }
    protected function execute(InputInterface $input, OutputInterface $output)
    {
    $output->writeln('Hello, world!!');
    }
    }
    αϒίϚϯυܕ(3)
    TZNGPOZDPOTPMF
    ͷίϚϯυΛ࡞Δͷͱ
    ͍͍ͩͨಉ͡

    View full-size slide

  58. ͓֮͑ͯ͘ͱྑ͍΋ͷ
    • ϓϥάΠϯ͸ComposerຊମͱಉҰϓϩηεͰಈ࡞
    • ෇ਵ͢ΔϥΠϒϥϦ࢖͍์୊
    • symfony/console, finder, json-schema...
    • require͠ͳͯ͘Α͍
    • composer.jsonͩͬͯಡΊΔͧ

    View full-size slide

  59. ϓϥάΠϯ։ൃͷ
    όουϊ΢ϋ΢

    View full-size slide

  60. ʊਓਓਓਓਓਓʊ
    ʼɹҙຯෆ໌ɹʻ
    ʉY^Y^Y^Y^Yʉ

    View full-size slide

  61. Τϥʔ͕ҙຯෆ໌
    • composer͸ඪ४ͷΤϥʔϋϯυϥ͕๫ྗత
    • E_NOTICE/E_DEPRECATEDͳͲͷΤϥʔ͕શ
    ͯϒϥοΫϗʔϧͷΑ͏ʹٵ͍ࠐ·Εɺ
    ErrorExceptionʹม׵͞ΕΔ
    • ελοΫτϨʔε͘ΕΑʂʂ

    View full-size slide

  62. ։ൃத͚ͩॻ͖׵͑ͯ͠·͑
    src/Composer/Util/ErrorHandler.php
    //...
    public static function register(IOInterface $io = null)
    {
    // set_error_handler(array(__CLASS__, 'handle'));
    error_reporting(E_ALL | E_STRICT);
    self::$io = $io;
    }

    View full-size slide

  63. Τϥʔͷى͖ͨߦ͕

    Θ͔Δ…ʂʂ

    View full-size slide

  64. ༨ஊͰ͚͢Ͳ
    • set_error_handler(...); ͢Δͱ͖͸ୈೋҾ਺ࢦ
    ఆ͠·͠ΐ͏Ͷ
    • શΤϥʔΛϒϥοΫϗʔϧͷΑ͏ʹٵ͍ࠐΉ
    ͷ͸ catch (\Exception $e) ͱಉ͡…ʂ
    • Pokémon Catching (CATCH 'EM ALL)

    View full-size slide

  65. ͋ͱ͸ࠔͬͨΒ
    • ιʔεΛಡΉ
    • composerଆʹvar_dumpΔ
    • ଞͷϓϥάΠϯΛpackagistͰ୳ͯ͠ιʔεΛಡΉ
    • σόοΨͰݟΔ

    (cliπʔϧͳͷͰphpdbg͕࢖͍΍͍͢)

    View full-size slide

  66. (͜͜·Ͱલஔ͖)

    View full-size slide

  67. ͦΖͦΖ
    ຊ୊

    View full-size slide

  68. ๯಄ͷεϥΠυΛ
    ͍֮͑ͯ·͔͢ʁ

    View full-size slide

  69. Composerͱ͸Կ͔ʁ

    View full-size slide

  70. ϥΠϒϥϦͷ

    ґଘؔ܎ղܾπʔϧ

    View full-size slide

  71. ͦΕ͚ͩʁ
    • ϓϥάΠϯΛݟΔͱɺଞʹ΋৭ʑͰ͖Δ͜ͱ͕Θ͔Δ
    • CLIπʔϧͷϑϨʔϜϫʔΫͰ΋͋Δ
    • λεΫϥϯφʔʹ΋ͳΔ
    • ։ൃπʔϧʹ΋ɺؤுΕ͹σϓϩΠπʔϧʹ΋
    • ͜Ε͸ҰମԿͩʁ

    View full-size slide

  72. ϥΠϒϥϦͷ

    ґଘؔ܎ղܾπʔϧ

    View full-size slide

  73. ComposerͷӅΕͨ໾ׂ
    • ϥΠϒϥϦΛ؅ཧ͢ΔͨΊʹ͸ʮϥΠϒϥϦʯ
    ͱ͸Կ͔Λఆٛ͠ͳͯ͘͸ͳΒͳ͔ͬͨ
    • ͦΕ͕Composer༻ޠͰݴ͏ͱ͜Ζͷ

    ύοέʔδ

    View full-size slide

  74. ຊ౰͸
    Composerͱ͸Կ͔ʁ

    View full-size slide

  75. ύοέʔδΛ࡞ΔͨΊͷ
    ϑϨʔϜϫʔΫ

    View full-size slide

  76. PHPʹ͓͚ΔϓϩάϥϜͷ୯Ґ
    1. 1ຕͷεΫϦϓτ
    2. require ʹΑΔϑΝΠϧ෼ׂ
    3. ؔ਺ / ΫϥεԽ
    4. ύοέʔδ
    5. αʔϏε (Microservices) 8FCΞϓϦέʔγϣϯ

    ϑϨʔϜϫʔΫͷର৅
    $PNQPTFS͸͜͜ʹ

    ఆٛΛ༩͑ͨ

    View full-size slide

  77. ͲΜͳෳࡶͳιϑτ΢ΣΞ΋ɺ
    ύοέʔδͷ֓೦ʹམͱ͠ࠐΊΔ
    ϝλ
    QBDLBHF
    ΂ΜΓ
    QBDLBHF
    QBDLBHF
    ΦϨΦϨ
    QBDLBHF
    ద౰
    QBDLBHF
    ࡶڕ
    QBDLBHF
    ࠷ߴ
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF
    QBDLBHF

    View full-size slide

  78. զʑ͸ԿΛ࡞͍ͬͯͨͷ͔
    • ύοέʔδΛ࡞͍ͬͯͨ
    • Composer͸ԿͰ΋ύοέʔδͱΈͳ͢
    • ʮPHPͰԿ͔Λ࡞Δʯ

    ʮComposerύοέʔδΛ࡞Δʯ

    ͍͍ͩͨಉ͡ҙຯ

    View full-size slide

  79. ͍·΍
    Composerͱ͸Կ͔ʁ

    View full-size slide

  80. ϓϩδΣΫτͷશͯΛ

    ঠѲ͢Δଘࡏ

    View full-size slide

  81. ʊਓਓਓਓਓਓਓਓʊ
    ʼɹcomposer.jsonɹʻ
    ʉY^Y^Y^Y^Y^Y^Yʉ

    View full-size slide

  82. ൴͸ͳΜͰ΋஌͍ͬͯΔ
    • ύοέʔδ͕ԿͰͲ͏͍͏໾ׂͳͷ͔
    • ඞཁͱ͍ͯ͠ΔϥΠϒϥϦ
    • ϓϩάϥϜͷىಈํ๏

    View full-size slide

  83. ͡Ό͋ɺComposerʹدͤΑ͏

    View full-size slide

  84. ϓϩδΣΫτΛ೺Ѳ্ͨ͠Ͱ

    ಈ࡞͢Δπʔϧ
    • ComposerϓϥάΠϯܗࣜͳΒ࣮ݱ͠΍͍͢
    • ࠓޙɺWebΞϓϦέʔγϣϯϑϨʔϜϫʔΫ
    ΍։ൃπʔϧ΋ɺcomposerϓϥάΠϯͷܗࣜ
    ͕૿͑Δ͔΋ɻ

    View full-size slide

  85. ·ͱΊ
    • Composer͸ύοέʔδͷϑϨʔϜϫʔΫͩ
    • composer.jsonʹ৘ใΛू໿͠ɺશͯཧղ͞
    ͤɺͦͷ্Ͱ։ൃ͢Δ
    • ·ͣ͸scriptsΛ࡞ͬͯΈͯʂ
    • ͦͷ্ͰϓϥάΠϯԽͯ͠ΈΔͱ͍͍Α

    View full-size slide