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

Composer 2.0って何?
どう変わるの?
読んでみました! / lets-read-...

Composer 2.0って何?
どう変わるの?
読んでみました! / lets-read-composer2!

PHP Conference Japan 2020での発表資料です

https://fortee.jp/phpcon-2020/proposal/7d06050f-a592-4869-b048-1795d2cb4fe3

hideki kinjyo

December 12, 2020
Tweet

More Decks by hideki kinjyo

Other Decks in Programming

Transcript

  1. ࣗݾ঺հ • ⾦城秀樹 / きんじょうひでき • GitHub: @o0h / Twitter:

    @o0h_ • 好きなFWはCakePHP • アイコンは 美味しい鮭親⼦丼の写真です
  2. Performance improvements • ϝϞϦ࢖༻ྔ΍଎౓໘ͰͷύϑΥʔϚϯεվળ • “I've seen reports of improvements

    of over 50% to both in some projects” (!!!!) • ґଘղܾͷํ๏ͷมߋɺฒྻDLͷಋೖɺϝλσʔλಡΈ ࠐΈͷվળͳͲ
  3. Partial updates with temporary constraints • ಛఆύοέʔδͷόʔδϣϯΛҰ࣌తʹߋ৽Ͱ͖ΔΑ͏ʹ • composer update

    hoge/fuga:2.* ͷΑ͏ʹར༻ • ͜͏͢Δͱcomposer.jsonϑΝΠϧ΍.lockϑΝΠϧͷ content-hashΛߋ৽͠ͳ͍ • (ύονόʔδϣϯͷࢦఆͳͲ) Ұ࣌తʹৄࡉͳࢦఆͰup/downgrade͍ͨ࣌͠ͳͲʹศརʂ
  4. ࢀߟʹͳΓͦ͏ͳจݙ • Composer 2.0 is now available! https://blog.packagist.com/composer-2-0-is-now- available/ •

    Composer 2: What's new and changed • PHP.Watch https://php.watch/articles/composer-2 ※ ։ൃத(2020-04࣌఺)ͷهࣄͳͷͰ஫ҙ
  5. v1ͷΩϟογϡػߏ • provider fileɺύοέʔδͷϝλϑΝΠϧ͸ϩʔΧϧʹΩϟογϡ͞ΕΔ • ࣍ճҎ߱ɺ·ͣ͸packages.jsonʹ໰͍߹ΘͤΔ • packages.jsonʹهࡌ͞Ε͍ͯΔ֤provider fileͷϋογϡ஋ͱ ϩʔΧϧʹ͋Δprovider

    fileͷϋογϡ஋Λൺֱ • ֤provider file͸ɺͦ͜ʹؚ·ΕΔύοέʔδ͕Կ͔͠Βߋ৽͞Εͨ৔ ߹ʹϋογϡ͕ߋ৽͞ΕΔ • ΋͠ϩʔΧϧʹ͋Δ΋ͷͱಉ͡ͳΒʮߋ৽ͳ͠ʯ => Ωϟογϡར༻
  6. v1 -> v2ͷมߋ఺ • provider filesΛҰ੾ಡΈࠐΜͰ͍ͳ͍ • DL΋ͯ͠ͳ͍͠ • ϝϞϦ΋࢖Θͣʮϝλ৘ใͷ৔ॴʯΛ೺ѲͰ͖͍ͯΔ

    • ܶతʹޮ཰্͕͕͍ͬͯΔ • ͪͳΈʹɺ ઌͷσϞಈը಺Ͱ࠷ॳͷϝλ৘ใͷDL։࢝࣌఺Ͱͷܦաඵ਺͸ v1͸15.04sɺv2ͩͱ0.33sͰ͢ ⾒逃しちゃうね
  7. lazy provider • ʮઌʹϦετશಡΈࠐΈ͠ͳͯ͘OKʯͰɺ஗Ԇ = lazy • ͨͩ͠ɺlazy providerͷ࢓૊Έࣗମ͸ੲ͔Β͋ͬͨ •

    https://github.com/composer/composer/commit/44e45ed (ϦϦʔεతʹ͸1.0.0αͷ΋ͷ) • ࣮ࡍʹv1ࣗମ͔Βར༻ྫ͕͋Δ • Packagistޓ׵ͷϨϙδτϦ • force-lazy-providersΦϓγϣϯ (see: composer/composer#4269)
  8. Ωϟογϡํࣜͷൺֱ • v1ͷ৔߹ɿ • cons: provider fileͷશಡΈࠐΈ͕ॏ͍ • pros: ࠷ྑͷέʔεͰ͸ɺpackages.jsonΛݟ͚ͨͩͰʮߋ৽ͳ͠ʯͱ֬ఆͰ͖

    Δ • v2ͷ৔߹: • cons: ύοέʔδ਺͚ͩඞͣϦΫΤετ͕ੜ͡Δ • pros: ࠷ѱͷέʔεͰ΋ɺύοέʔδ෼ͷϝλσʔλͷྔ͔͠௨৴͠ͳ͍ͰࡁΉ
  9. v2: post ext-curl & curl_mutli • v2Ͱʮmetadata-urlʯۦಈͰΩϟογϡνΣοΫͰ͖Δͷ͸ɺ curlͷར༻΍ฒྻ௨৴ͷར༻ʹ଩Λ੾͔ͬͨΒ • file_get_contents()ͷύϑΥʔϚϯε໰୊͸ɺ

    ͔ͶͯΑΓٞ࿦ʹ্͕͍ͬͯͨ • ͨͩ͠ɺ(composer.jsonΛݟͨΒ෼͔ΔΑ͏ʹ) ext-curlΛඞਢʹ͸͍ͯ͠ͳ͍ɻ͋͘·Ͱʮ͋Ε͹ૣ͘ͳΔʯ࣮૷
  10. ʮൈຊతʯͱ͍͑Δมߋ෦෼Λ௥͍͍ͨ • pull#7625: Separate RepositorySet from Package Pool, load only

    metadata of packages directly required by naderman • ʮDLͱΠϯετʔϧ(vendorσΟϨΫτϦߋ৽)ͷ෼཭ʯΛ ਐΊΔ΋ͷ • pull #8755: Add options to configure repository priorities by Seldaek • ϨϙδτϦؒͷ༏ઌ౓ΛઃఆͰ͖ΔΑ͏ʹ͢Δ΋ͷ