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

夢を詰め込む話@PHP BLT#5

夢を詰め込む話@PHP BLT#5

PHPP BLT#5で発表しました。

Sota Sugiura

July 20, 2016
Tweet

More Decks by Sota Sugiura

Other Decks in Technology

Transcript

  1. QIBS GSPNQIQOFU QIBS֦ுϞδϡʔϧ͸ɺ1)1ΞϓϦέʔγϣϯશମΛͻͱͭͷQIBS 1)1"SDIJWF ϑΝΠ ϧʹ·ͱΊͯ͠·͍ɺ഑෍΍ΠϯετʔϧΛ༰қʹ͢ΔͨΊͷ΋ͷͰ͢ɻͦΕ͚ͩͰͳ͘ɺQIBS ֦ுϞδϡʔϧͰ͸ϑΝΠϧϑΥʔϚοτΛந৅Խ͢Δػೳ΋ఏڙ͓ͯ͠ΓɺUBSܗࣜ΍[JQܗࣜ ͷϑΝΠϧΛ1IBS%BUBΫϥεͰѻ͏͜ͱ͕Ͱ͖·͢ɻͪΐ͏Ͳ1%0͕͞·͟·ͳσʔλϕʔε ΁ͷ౷ҰΠϯλʔϑΣΠεΛ༻ҙ͍ͯ͠Δͷͱಉ͡Α͏ͳ΋ͷͰ͢ɻ1%0Ͱ͸ҟͳΔσʔλϕʔε ؒͷม׵͸Ͱ͖·ͤΜ͕ɺQIBSͰ͸UBSɺ[JQɺQIBSϑΝΠϧϑΥʔϚοτؒͷม׵͕ίʔυ

    ߦ͚ͩͰͰ͖ͯ͠·͍·͢ɻྫͱͯ͠1IBSDPOWFSU5P&YFDVUBCMF Λࢀর͍ͩ͘͞ɻ 1IBSͬͯԿ 1IBSΞʔΧΠϒ͸ɺෳ਺ͷϑΝΠϧΛͻͱͭʹ·ͱΊΔͨΊͷศརͳ࢓૊ΈͰ͢ɻ 1IBSΞʔΧΠϒΛ࢖༻͢Ε͹ɺ1)1ͷΞϓϦέʔγϣϯΛͻͱͭͷϑΝΠϧͱͯ͠഑෍Ͱ͖ΔΑ ͏ʹͳΓ·͢ɻ·ͨɺͦΕΛσΟεΫ্ʹల։͠ͳͯ͘΋ͦͷ··࣮ߦͰ͖ΔͷͰ͢ɻ͞Βʹɺଞ ͷϑΝΠϧͱಉ༷ʹ1)1͔ΒQIBSΞʔΧΠϒΛ࣮ߦ͢Δ͜ͱ͕Ͱ͖·͢ɻίϚϯυϥΠϯͱ΢Σ ϒαʔόʔܦ༝ͷͲͪΒͰ΋࣮ߦՄೳͰ͢ɻQIBS͸ɺ͍Θ͹1)1ΞϓϦέʔγϣϯʹ͓͚Δ UIVNCESJWFͷΑ͏ͳ΋ͷͰ͢ɻ 1IBS͸͜ͷػೳΛ࣮૷͢ΔͨΊʹετϦʔϜϥούʔΛ࢖༻͍ͯ͠·͢ɻ௨ৗ͸ɺ1)1εΫϦ ϓτ͔Β֎෦ͷϑΝΠϧΛ࢖༻͢Δʹ͸JODMVEFΛ༻͍·͢ɻ IUUQQIQOFUNBOVBMKBJOUSPQIBSQIQΑΓग़య
  2. ௒ࡶʹݕূ <?php class Compiler { /* ௒লུ */ private $counter

    = 0; public function compile($pharFile = 'composer.phar') { /* ௒লུ */ echo $this->counter; } private function addFile($phar, $file, $strip = true) { $this->counter++; /* ௒লུ */ }
  3. ѹॖ͢Δ΍ͭΒ <?php // app.php require __DIR__ . '/calculate.php'; echo add(1,

    3); <?php // calculate.php function add($a, $b) { return $a + $b; }
  4. QIBS࡞੒ίʔυ <?php // pharϑΝΠϧ࡞੒ $phar = new Phar('app.phar'); // ΞʔΧΠϒʹϑΥϧμ௥Ճ

    $phar->buildFromDirectory(__DIR__); // ىಈ࣌ʹ࣮ߦ͞ΕΔελϒΛઃఆ $phar->setStub(createStub()); function createStub() { return <<<'EOD' <?php require 'phar://app.phar/app.php'; __HALT_COMPILER(); EOD; }