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

独自フレームワークPHPアプリケーションの改善戦略 / Original Framework PHP Kaizen

tzmfreedom
October 02, 2021

独自フレームワークPHPアプリケーションの改善戦略 / Original Framework PHP Kaizen

PHP Conference Japan 2021の発表資料です。
https://fortee.jp/phpcon-2021/proposal/7ae96df3-84a7-4d5d-a496-bd9b72841219

tzmfreedom

October 02, 2021
Tweet

More Decks by tzmfreedom

Other Decks in Technology

Transcript

  1. גࣜձࣾϠϓϦా࣮੣
    ಠࣗϑϨʔϜϫʔΫ
    1)1ΞϓϦέʔγϣϯͷվળઓུ

    View full-size slide

  2. ࣗݾ঺հ
    w ా࣮੣!U[N@GSFFEPN
    w גࣜձࣾϠϓϦͷαʔόʔαΠυΤϯδχΞ
    w 1)1ྺ͸̏ʙ೥͘Β͍
    w 1)1FS,BJHJͰ͸1)1Ͱ1)1Λ࣮૷ͯ͠·ͨ͠

    View full-size slide

  3. ࠓ೔࿩͢͜ͱ
    wಠࣗϑϨʔϜϫʔΫ1)1ΞϓϦέʔγϣϯͷվળํ๏
    wվળͷਐΊํɺઓུ
    ˞֤ٕज़ͷৄࡉ͸͋·Γ࿩͠·ͤΜ🙏

    View full-size slide

  4. ಠࣗϑϨʔϜϫʔΫͰ΋ఘΊͳ͍Ͱʂ

    View full-size slide

  5. :BQQMJʹ͍ͭͯ
    w ϊʔίʔυͰΞϓϦΛ࡞ΕΔϓϥοτϑΥʔϜ
    w εϐʔυಋೖ
    w ೥ؒҎ্ͷΞοϓσʔτ
    w ଟ࠼ͳϓογϡ௨஌
    w ಋೖ࣮੷ࣾҎ্
    w ૯μ΢ϯϩʔυ਺໿ສ

    View full-size slide

  6. :BQQMJͷΞʔΩςΫνϟʹ͍ͭͯ
    w 8FCͷίϯςϯπ؅ཧը໘ʢ$.4ʣͰίϯςϯπΛฤू

    ΞϓϦ͔Β"1*Λୟ͍ͯίϯςϯπσʔλΛऔಘ

    औಘͨ͠ίϯςϯπσʔλΛ࢖ͬͯը໘දࣔ
    ࠓ೔࿩͢ͷ͸͜ͷ"1*ʹ͍ͭͯ

    View full-size slide

  7. "1*ͷ֓ཁ
    w ωΠςΟϒΞϓϦ޲͚ͷ"1*
    w $.4Ͱઃఆͨ͠ίϯςϯπ৘ใΛ഑৴͍ͯ͠Δ
    w ϦΫΤετ਺ʙ SQT
    w -0$ʙ਺ສߦ
    w "1*ΤϯυϙΠϯτ਺ʙ
    w ։ൃظؒ೥͔Β

    View full-size slide

  8. "1*ͷίʔυ
    w JODMVEF0SJFOUFEͳಠࣗϑϨʔϜϫʔΫ
    w ΄ͱΜͲ͕ΫϥεԽɺؔ਺Խ͞Ε͍ͯͳ͍εΫϦϓτͰߏ੒
    w ৑௕ͳॏෳίʔυ
    w ࿈૝഑ྻϕʔεͰͷม਺΍ΓͱΓ
    w ςετίʔυʗ੩తղੳͳ͠

    View full-size slide

  9. ಠࣗϑϨʔϜϫʔΫͷߏ଄
    w ਌ϑΝΠϧࢠϑΝΠϧଙϑΝΠϧͷJODMVEFϦϨʔ
    w ݺͼग़͠ݩϑΝΠϧͰఆٛͨ͠ม਺ɾؔ਺Λݺͼग़͠ઌͰར༻
    JODMVEFͰݺͼग़͠
    $application = [ ... ]
    ;

    // ...
    // ࢠεΫϦϓτͷݺͼग़͠
    $scriptPath = getScript($requestPath)
    ;

    include "/path/to/root/$scriptPath";
    if ($application['xxx'] === 'yyy')
    {

    // ...
    }

    // ଙεΫϦϓτͷݺͼग़͠
    $scriptPath = getScript($_GET)
    ;

    include "/path/to/root/$scriptPath";

    View full-size slide

  10. ๊͍͑ͯͨ՝୊
    w ػೳ௥ՃɺϦϑΝΫλϦϯά͕ͮ͠Β͍
    w खಈͰಈ࡞֬ೝΛ͢Δ·Ͱਖ਼ৗʹಈ͔͘อূͰ͖ͳ͍
    w ॲཧ͕ΫϥεԽɺؔ਺Խ͞Ε͍ͯͳ͍ͷͰςετ΋ॻ͖ͮΒ͍
    w ৑௕ͳॏෳίʔυ͕͋Γڞ௨ॲཧΛೖΕʹ͍͘
    w ϩάϨϕϧ͕ೖ͓ͬͯΒͣɺ؂ࢹ΍τϨʔε͕ͮ͠Β͍

    View full-size slide

  11. վળઓུͱํ๏

    View full-size slide

  12. ઓུ
    w খ࢝͘͞ΊΔ
    w μϝͩͬͨΒ͙͢ʹࣺͯΕΔΑ͏ʹ
    w ίʔυमਖ਼Λ͠ͳ͍վળํ๏͔Βணखɻ֎ງ͔ΒຒΊ͍ͯ͘
    w ׬ᘳΛٻΊͳ͍ɻ·ͣ͸͜Μͳײ͡ɺͰͪΐͬͱͣͭਐΊΔ
    w ίεύΛҙࣝ
    w "1*վળҎ֎ʹ΋Ϗδωεతɾٕज़తʹ΍Γ͍ͨ͜ͱ͸ແݶʹ͋Δ

    View full-size slide

  13. ՝୊ɿػೳ௥Ճɾมߋ͕ͮ͠Β͍

    View full-size slide

  14. ղܾํ๏̍ࣗಈςετಋೖ

    View full-size slide

  15. ࣗಈςετ
    w Կ͸ͱ΋͋Εςετίʔυ
    w ػೳ௥ՃɺϦϑΝΫλϦϯά͢Δ্ͰσάϨ͍ͯ͠ͳ͍͔Ͳ͏͔ͷ
    อূΛಘ͍ͨ
    w 1)1΍ϥΠϒϥϦͷΞοϓάϨʔυ࣌ͷ࠷௿ݶͷಈ࡞อূ
    w ڥք஋ͷ୯ମςετΛॻ͍ͯ҆৺ײΛಘ͍ͨ
    w ςετΛॻ͖΍͍͢ίʔυʹྑ͍ίʔυͱͳΔΑ͏ͳઃܭͷΧφϦ
    Ξతظ଴

    View full-size slide

  16. ࣗಈςετͰ΍Γ͍ͨ͜ͱ
    w ϩʔΧϧ؀ڥɺ$*؀ڥͰςετͷ࣮ߦ

    %PDLFS$JSDMF$*
    w ୯ମςετ

    1)16OJU
    w "1*ςετʢ݁߹ςετʣ
    w ΧόϨοδूܭ

    View full-size slide

  17. Ұൠతͳ"1*ςετ
    w Ұൠతʹ"1*ςετ͸ΫϥεϕʔεͰߦΘΕΔ͜ͱ͕ଟ͍
    w ྫ͑͹-BSBWFM΍4ZNGPOZͰ͸"1*ςετ͸Ծ૝తͳϦΫΤε
    τʢʹͨͩͷΫϥεɾϝιουݺͼग़͠ʣͰߦ͍ͬͯΔ
    w ࠓճ͸ΫϥεϕʔεͰ͸ͳ͍ͷͰผͷΞϓϩʔν͕ඞཁ

    View full-size slide

  18. ࣮αʔόʔΛ্ཱͪ͛ͨ"1*ςετ
    w %PDLFSίϯςφͳ"1*αʔόʔΛ্ཱͪ͛Δ
    w "1*ϦΫΤετΛߦͬͯϨεϙϯεͳͲͷݕূΛߦ͏
    w ίʔυΛมߋ͢Δඞཁ͕ͳ͘ɺςετͷδϨϯϚʹͳΒͳ͍
    w ςετΛॻ͘ݴޠ΍ϑϨʔϜϫʔΫʹґΒͳ͍
    w ࠓճ͸ίϯςΩετεΠον΍ֶशίετΛߟྀͯ͠1)16OJU
    Λબ୒

    View full-size slide

  19. "1*ςετίʔυྫ
    fi
    nal class PhotoTest extends TestBase
    {

    public function test_Ұཡදࣔ(
    )

    {

    $client = new GuzzleHttp\Client()
    ;

    $res = $client->get(self::HOST. self::PATH, [])
    ;

    $actual = json_decode($response->getBody()->getContents(), true)
    ;

    $this->assertSame(
    [

    // ...
    ], $actual)
    ;

    }

    }

    View full-size slide

  20. "1*ςετͷϞοΫ
    w ࣮αʔόͷ"1*ςετͰ΋ಛఆͷϞδϡʔϧΛϞοΫ͍ͨ͠
    w ୯ମςετͰ͋Ε͹ϞοΫ͢ΔॲཧΛݺͼग़ͤ͹ྑ͍
    w 1)17$3 $BSCPOTFU5FTU/PX
    VPQ[ ʜ
    w ͕ɺࠓճ͸ςετͱςετର৅͕ผϓϩηεʹͳ͍ͬͯΔͷͰ
    1)16OJUͷϓϩηεͰϞοΫΛݺͼͩͯ͠΋ϞοΫ͕Ͱ͖ͳ͍

    View full-size slide

  21. BVUP@QSFQFOE@GJMFʹΑΔϞοΫ
    w OHJOY΍BQBDIFͰ1)1ͷεΫϦϓτΛݺͼग़͢લʹ࣮ߦ͢Δ
    1)1ͷϑΝΠϧΛࢦఆͰ͖Δ
    w ຊ൪Ͱ͸Մಡੑͷ؍఺Ͱ͋·Γ࢖ΘΕ͍ͯͳ͍ʢ͸ͣͷʣٕज़
    w ϞοΫʹ࢖͏ؔ਺ΛαʔόʔଆͷBVUP@QSFQFOE@
    fi
    MFʹ࢓ࠐΊ͹
    ςετ༻"1*αʔόʹϦΫΤετͨ͠ͱ͖͚ͩϞοΫͰ͖Δʂ
    fastcgi_param PHP_VALUE "auto_prepend_
    fi
    le=\"/path/to/
    fi
    le\"";

    View full-size slide

  22. $cassetteName = $_SERVER['HTTP_X_VCR_CASSETTE_NAME']
    ;

    $mockTime = $_SERVER['HTTP_X_CURRENT_TIMESTAMP']
    ;

    if ($mockTime !== '')
    {

    $time = Carbon::parse($mockTime)
    ;

    Carbon\Carbon::setTestNow($time)
    ;

    }

    if ($cassetteName !== '')
    {

    ini_set('opcache.enable', 0)
    ;

    \VCR\VCR::con
    fi
    gure(
    )

    ->setCassettePath(__DIR__ . '/tests/cassette')
    ;

    \VCR\VCR::turnOn()
    ;

    \VCR\VCR::insertCassette($cassetteName)
    ;

    }
    ϦΫΤετϔομͰϞοΫઃఆΛऔಘ
    $BSCPOͰ࣌ؒΛϞοΫ
    7$3Ͱ)551ϦΫΤετΛϞοΫ

    View full-size slide

  23. ΧόϨοδूܭ
    w "1*ςετʢ&&ʣͰ΋ΧόϨοδूܭ͍ͨ͠
    w ਺ࣈΛग़͢͜ͱͰςετΛॻ͘ϞνϕʔγϣϯʹͳΔ
    w 1)16OJUͱϓϩηε͕ҟͳΔ"1*αʔόʔͰͲ͏΍ͬͯΧόϨ
    οδΛूܭ͢Δʜʁ

    View full-size slide

  24. BVUP@QSFQFOE@GJMFʹΑΔΧόϨοδूܭ
    w YEFCVHͷؔ਺Λ࢖͏ͱΧόϨοδܭଌ͕Ͱ͖Δ
    w औಘͨ͠ΧόϨοδσʔλΛϑΝΠϧʹอଘ
    w ΫϥεͷσετϥΫλͰ"1*ͷॲཧऴྃ࣌ʹಈ͔͢

    ʢSFHJTUFS@TIVUEPXO@GVODUJPOͰ΋0,
    w ςετऴྃޙɺΧόϨοδΛूܭ͠)5.-Խ
    w IUUQTHJUIVCDPNTFCBTUJBOCFSHNBOOQIQDPEF
    DPWFSBHF

    View full-size slide

  25. class CoverageDumper
    {

    function __destruct(
    )

    {

    $coverageName = ‘/path/to/coverage-‘ . microtime(true);
    xdebug_stop_code_coverage(false)
    ;

    $codecoverageData = json_encode(xdebug_get_code_coverage())
    ;

    fi
    le_put_contents($coverageName . '.json', $codecoverageData)
    ;

    }

    }

    xdebug_start_code_coverage
    (

    XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_COD
    E

    )
    ;

    $coverageDumper = new CoverageDumper();
    ΧόϨοδܭଌ։࢝
    ΧόϨοδܭଌ݁ՌͷϑΝΠϧॻ͖ग़͠

    View full-size slide

  26. $
    fi
    nalCoverage = new SebastianBergmann\CodeCoverage\CodeCoverage()
    ;

    $
    fi
    lter = $
    fi
    nalCoverage->
    fi
    lter()
    ;

    $
    fi
    lter->addDirectoryToWhitelist("/path/to/dir")
    ;

    $coverages = glob('./coverage/coverage-*.json')
    ;

    foreach ($coverages as $coverageFile
    )

    {

    $codecoverageData = json_decode(
    fi
    le_get_contents($coverageFile))
    ;

    $testName = str_ireplace(basename($coverageFile,".json"),"coverage-", "")
    ;

    $
    fi
    nalCoverage->append($codecoverageData, $testName)
    ;

    }

    $
    fi
    nalCoverage->merge(include './coverage/phpunit.php')
    ;

    $report = new \SebastianBergmann\CodeCoverage\Report\Html\Facade()
    ;

    $report->process($
    fi
    nalCoverage, 'reports');
    "1*ςετͷશΧόϨοδϑΝΠϧΛूܭɾϚʔδ
    ୯ମςετͷΧόϨοδϑΝΠϧΛϚʔδ
    ΧόϨοδΛ)5.-Ͱॻ͖ग़͠

    View full-size slide

  27. ͋ͱ͸ςετΛॻ͍͍͚ͯͩ͘ʜʂ
    ʢݱࡏΧόϨοδ͘Β͍

    View full-size slide

  28. ղܾํ๏̎੩తղੳಋೖ

    View full-size slide

  29. 1)1ͱ੩తղੳ
    w ੩తղੳπʔϧΛ࢖͏ͱΏΔ;Θ1)1͕੩తܕ෇͚ݴޠʹͳΔ
    w γϯλοΫεΤϥʔ΍λΠϙͳͲͷ୯७ͳΤϥʔΛ๷͛ΔͨΊ
    ಈతܕ෇͚ݴޠͷऑ఺Λ͔ͳΓิ͑Δ
    w ઃఆʹΑͬͯܕ෇͚ͷڧ౓Λબ୒Ͱ͖ΔͨΊಋೖ͠΍͍͢
    w ΃ͪ͜Μ΍1)1FS,BJHJͰ΋͍͍ͩͨ੩తղੳͷ࿩୊͕ೖͬͯ
    ͖͍ͯΔ͘Β͍ʹ͸ίϞσΟςΟԽͨ͠ײ

    View full-size slide

  30. 1)14UBOͷಋೖ
    w IUUQTHJUIVCDPNQIQTUBOQIQTUBO
    w ੩తղੳͷ୅දతͳπʔϧͷ̍ͭ
    w ΧελϜϧʔϧͰಠࣗͷ੩తղੳ΋Ͱ͖Δ
    w ެࣜɺSEQBSUZͷFYUFOTJPO΋ॆ࣮

    View full-size slide

  31. parameters
    :

    level: 0
    bootstrapFiles
    :

    - %rootDir%/../../../phpstan.bootstrap.php
    ignoreErrors
    :

    - ’#xxxx#’

    $ php ./vendor/bin/phpstan analyse --memory-limit=-1 /path/to/dir
    w·ͣ͸CBTFMJOF΍ɺͬ͘͟ΓJHOPSF&SSPSTͯ͠ελʔτ
    wϨϕϧΛ্͍͔͛ͯ͘ϧʔϧΛݸผ௥Ճ͍͔ͯ͘͠

    View full-size slide

  32. 1)1%PDʹΑΔܕ৘ใͷ෇༩
    w 1)14UBOY1)1%PDͰ1)1ͷόʔδϣϯʹґΒ༷ͣʑͳ৔ॴ
    ʹܕ͕෇༩Ͱ͖Δ
    w ຊମΑΓڧྗͳܕ෇͕Ͱ͖ΔʢBSSBZTIBQFɺ!UFNQMBUFʣ
    w ϚδοΫϝιου΋!QSPQFSUZ !NFUIPEͰղੳͰ͖Δ
    w ࣮ମ͸ίϝϯτͳͷͰɺڍಈΛյͣ҆͞৺ͯ͠ಋೖͰ͖Δ
    w 1)14UPSNͳͲͷิ׬΋ޮ͘ͷͰೖΕͨ΄͏͕ྑ͍

    View full-size slide

  33. BSSBZTIBQF
    w ഑ྻɺ࿈૝഑ྻʹର͢ΔܕΛಋೖ͢Δ͜ͱ͕Ͱ͖Δ
    w ࿈૝഑ྻϔϏʔϢʔεͳΞϓϦέʔγϣϯʹ͸͔ͳΓخ͍͠
    w ࿈૝഑ྻʹؔ͢ΔλΠϙΛ๷͛Δ
    /*
    *

    * @param array{hoge: string, fuga: boolean} $optio
    n

    * @return bool
    */
    public static function isHoge($option) {}

    View full-size slide

  34. 6OEFGJOFEWBSJBCMF໰୊ͷճආํ๏
    w ʢ࠶ܝʣ਌ϑΝΠϧͰఆٛͨ͠ม਺ɾؔ਺ΛࢠϑΝΠϧͰ࢖͍ͬͯΔ
    w ࢠϑΝΠϧΛͦͷ··ղੳͨ͠Β6OEF
    fi
    OFEWBSJBCMF 'VODUJPOOPU
    FYJTUTࡇΓ
    w ϑΝΠϧͷઌ಄ʹ1)1%PDͷม਺એݴʢ!WBSʣΛೖΕΔ͜ͱͰճආ
    Մೳ͕ͩɺࢠϑΝΠϧશͯʹೖΕͳ͍ͱ͍͚ͳ͍ͨΊอकੑ͕ѱ͍
    w Ұ୴JHOPSF&SSPSTͰճආʢ͋Δఔ౓ͷGBMTFOFHBUJWF͸ڐ༰ʣ

    View full-size slide

  35. ςετίʔυͱ੩తղੳͰ֎ງΛຒΊͨͷͰ

    ͋ͱ͸߈Ί์୊ʂϦϑΝΫλϦϯάແ૒ʂ

    View full-size slide

  36. ՝୊ɿॏෳίʔυ

    View full-size slide

  37. ࣄલ४උؔ਺ͷJODMVEFରࡦ
    w ఆٛͨؔ͠਺ϑΝΠϧΛSFRVJSF΍JODMVEFͯ͠ಡΈࠐΜͰ͍ͨ
    w ͦΕΒͷؔ਺ʹ͸΄ͱΜͲ໊લۭ͕ؒઃఆ͞Ε͍ͯͳ͔ͬͨ
    w ؔ਺ͷೋॏఆٛΛ͠ͳ͍Α͏ʹGVODUJPO@FYJTUTͰΨʔυ͍ͯͨ͠
    w GVODUJPO@FYJTUT࿙ΕʹΑΔෆ۩߹΋͋ͬͨΓͨ͠
    w ಡΈࠐ·Ε͍ͯΔ͔Ͳ͏͔ΛҙࣝͤͣʹJODMVEFͭͭ͠ɺؔ਺໊͕
    όοςΟϯά͠ͳ͍Α͏ʹ໊લۭؒΛ࢖͍͍ͨ

    View full-size slide

  38. ࣄલ४උBVUPMPBEԽ
    w طʹDPNQPTFS΍BVUPMPBEΛҰ෦ར༻͍ͯͨ͠ͷͰɺ
    BVUPMPBE͍ͯ͠Δ143ͳσΟϨΫτϦʹࡶʹTUBUJDϝιο
    υΛಥͬࠐΜͩ
    w ੩తղੳಋೖޙʹߦͬͨͷͰ҆৺ͯ͠ϦϑΝΫλϦϯά
    w ϦϑΝΫλϦϯάͷͱ͖ʹVTF࿙Εͱ͔Α͋͘Δʜ

    View full-size slide

  39. )551ϦΫΤετͷॏෳίʔυ໰୊
    w )551ϦΫΤετ͸DVSMؔ਺͕ϝΠϯͩͬͨ
    w DVSMؔ਺ͷϋϯυϦϯά͸೉͍͠
    w DVSM@JOJU DVSM@DMPTF DVSM@JOGP DVSM@TFUPQU ʜ
    w ؔ਺Խʗڞ௨Խ΋΄ͱΜͲ͞Εͯͳ͔ͬͨ

    View full-size slide

  40. $ch = curl_init()
    ;

    curl_setopt($ch, CURLOPT_URL, 'http://api.example.com/path')
    ;

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5)
    ;

    curl_setopt($ch, CURLOPT_TIMEOUT, 5)
    ;

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)
    ;

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)
    ;

    curl_setopt($ch, CURLOPT_POST, 1)
    ;

    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([ ... ]))
    ;

    $res = curl_exec($ch)
    ;

    if (!curl_errno($ch))
    {

    $info = curl_getinfo($ch)
    ;

    if ($info['http_code'] === 200)
    {

    // ...
    }

    }

    curl_close($ch);
    DVSM@TFUPQUͷཛྷ
    ΤϥʔνΣοΫ͕େม
    DMPTF

    View full-size slide

  41. (V[[MFʹΑΔ)551ϦΫΤετڞ௨Խ
    w IUUQTHJUIVCDPNHV[[MFHV[[MF
    w ௚ײతʹ)551ϦΫΤετ͕ଧͯΔ
    w ΤϥʔϋϯυϦϯά΋&YDFQUJPOεϩʔͳͷͰΘ͔Γ΍͍͢

    View full-size slide

  42. $response = self::getClient()->post('/path',
    [

    'form_params' => [ ... ]
    ,

    'headers' => [ ... ]
    ,

    ])
    ;

    $body = $response->getBody()
    ;

    return json_decode($body, true);
    $ch = curl_init()
    ;

    curl_setopt($ch, CURLOPT_URL, 'http://
    api.example.com/path')
    ;

    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5)
    ;

    curl_setopt($ch, CURLOPT_TIMEOUT, 5)
    ;

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1)
    ;

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1)
    ;

    curl_setopt($ch, CURLOPT_POST, 1)
    ;

    curl_setopt($ch, CURLOPT_POSTFIELDS,
    http_build_query([ ... ]))
    ;

    $res = curl_exec($ch)
    ;

    if (!curl_errno($ch))
    {

    $info = curl_getinfo($ch)
    ;

    if ($info['http_code'] === 200)
    {

    // ...
    }

    }

    curl_close($ch);

    View full-size slide

  43. ՝୊ɿϩΪϯά

    View full-size slide

  44. ϩΪϯάͷ՝୊
    w ΄΅FSSPS@MPH
    ؔ਺ͰϩΪϯά͍ͯͨ͠
    w ϩάϨϕϧ͕ͳ͘؂ࢹ͕೉͍͠
    w ڞ௨ॲཧ΋ೖΕΒΕͳ͍
    w ϚΠΫϩαʔϏεʹର͢ΔϦΫΤετ΋͋ΔͨΊ

    ϩάʹϦΫΤετ*%ΛೖΕͯ෼ࢄτϨʔγϯά͍ͨ͠

    View full-size slide

  45. .POPMPHʹΑΔϩΪϯάڞ௨Խ
    w IUUQTHJUIVCDPN4FMEBFLNPOPMPH
    w &SSPS-PH)BOEMFSΛ࢖ͬͯFSSPS@MPHʹग़ྗ͢ΔํࣜΛ౿ऻ
    w ੾Γ໭͠ͷ͠΍͢͞Λҙࣝ
    w มߋ͢Δ৔߹͸)BOEMFSΛࠩ͠ସ͑Δ͚ͩͰྑ͍
    w 1SPDFTTPSΛ࢖ͬͯϦΫΤετ*%΋ϩάʹग़ྗ

    View full-size slide

  46. w ࣮ࡍʹ͸͜ΕΛϥοϓͨ͠TUBUJDϝιουΛఆٛͯ͠ϩΪϯά
    public static function getLogger(
    )

    {

    self::$logger = (new \Monolog\Logger($env))
    )

    ->pushHandler(new \Monolog\ErrorLogHandler()
    )

    ->pushProcessor(function($record)
    {

    $record['extra']['uid'] = self::getRequestID()
    ;

    return $record
    ;

    })
    ;

    return self::$logger
    ;

    }

    View full-size slide

  47. <4FQ>QSPE*/'0SFRVFTUTUBSUʜ\VJEGECEGCFE^

    <4FQ>QSPE*/'0SFRVFTUFOEʜ\lVJEGECEGCFE^
    ϩΪϯάڞ௨Խ
    <4FQ>SFRVFTUTUBSUʜ

    <4FQ>SFRVFTUFOEʜ
    w ڞ௨Խͨ͠ͷͰΞϓϦͷࣝผࢠͳͲΛೖΕΔ͜ͱ΋ՄೳʹͳΓɺखܰ
    ʹτϨʔεৄࡉ౓Λௐ੔Ͱ͖ΔΑ͏ʹͳͬͨ

    View full-size slide

  48. ՝୊ͱվળํ๏ͷ·ͱΊ

    View full-size slide

  49. ͔ͳΓվળ͠·ͨ͠
    w ػೳ௥ՃɺϦϑΝΫλϦϯά͕ͮ͠Β͍ɻखಈͰಈ࡞֬ೝΛ
    ͢Δ·Ͱਖ਼ৗʹಈ͔͘อূͰ͖ͳ͍

    ࣗಈςετɺ੩తղੳ
    w ৑௕ͳॏෳίʔυʹΑΓɺڞ௨ॲཧΛೖΕʹ͍͘

    BVUPMPBEԽɺద੾ͳϥΠϒϥϦಋೖɺϦϑΝΫλϦϯά
    w ϩάϨϕϧ͕ೖ͓ͬͯΒͣɺ؂ࢹ΍τϨʔε͕ͮ͠Β͍

    ϩΨʔΫϥεͷಋೖ

    View full-size slide

  50. ಠࣗ'81)1ΞϓϦέʔγϣϯͷվળํ๏
    w 8FCΞϓϦͰΑ͘औΓ૊·Ε͍ͯΔվળΛ΍͚ͬͨͩ
    w ಠࣗϑϨʔϜϫʔΫͰ΋΍Δ͜ͱ͸ͦ͜·ͰมΘΒͳ͍
    w ՝୊Λਖ਼͘͠ೝࣝ͢Δ͜ͱɺϓϩμΫτɾνʔϜʹ߹ͬͨਐΊ
    ํͷ໛ࡧɺͦͯ͠վળ΁ͷߦಈ͕େࣄ

    View full-size slide

  51. ಠࣗϑϨʔϜϫʔΫͰ΋ఘΊͳ͍Ͱʂ

    View full-size slide

  52. ϓϩμΫτΛΑΓྑ͍ͯͨ͘͘͠Ίʹ

    View full-size slide

  53. վળ΁Ұา౿Έग़͢
    w վળɺϦϑΝΫλϦϯάʹΑΔෆ۩߹͸ා͍
    w Ͱ΋΍Βͳ͍ͱ΋ͬͱμϝʹͳΔɻׂΕ૭ʹͳΔɻ
    w վળ΍ࣦഊΛ܁Γฦ͢͜ͱͰΤϯδχΞϦϯάྗ͕޲্͢Δ
    w ςετίʔυ΍ϦϑΝΫλϦϯάͨ͠ܦݧ͕ઃܭྗʹ׆͖Δ
    w վળͷϦεΫ؅ཧྗ΍࿹ྗͷ޲্
    w ࣦഊ͸՝୊Λൃݟ͍ͯͨ͘͠Ίʹඞཁͳϓϩηε

    View full-size slide

  54. ϓϩμΫτΛΑΓྑ͍ͯͨ͘͘͠Ίʹ
    w ϨΨγʔɺಠࣗ'8ͷ໰୊Ͱ͸ͳ͘ɺΦʔφʔγοϓͷ໰୊ʁ
    w ͋͑ͯࠓճϨΨγʔͱ͍͏ݴ༿Λ࢖Θͳ͔ͬͨͷ͸ɺϨΨγʔ
    ͱ͍͏ݴ༿ʹҧ࿨ײΛײ࢝͡Ί͍͔ͯͨΒ
    w ଞͷ୭͔͕ॻ͍ͨίʔυɺ୭͔͕࡞ͬͨϓϩμΫτͰ͸ͳ
    ͘ɺࣗ෼ୡͷϓϩμΫτͷίʔυ
    w ୭͕ॻ͍ͨίʔυͰ͋ͬͯ΋ΦʔφʔγοϓΛ࣋ͬͯऔΓ૊Μ
    Ͱߦ͖͍ͨ

    View full-size slide

  55. ྑ͍ϓϩμΫτΛ࡞͍͖ͬͯ·͠ΐ͏ʂ

    View full-size slide