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

25分で理解する!Symfonyの魅力とその実践的活用法

Ippei Sumida
October 08, 2023

 25分で理解する!Symfonyの魅力とその実践的活用法

PHP Conference Japan 2023でお話ししたスライドです。 #phpcon #phpcon2023

Ippei Sumida

October 08, 2023
Tweet

More Decks by Ippei Sumida

Other Decks in Programming

Transcript

  1. Symfony: 4ͭͷ֓೦ 1. Components 2. Framework 3. Community 4. Philosophy

    200Ҏ্ͷίϯϙʔωϯτ܈ ίϯϙʔωϯτΛར༻ͨ͠ϑϨʔϜϫʔΫ ͦΕΒΛࢧ͑ΔίϛϡχςΟ SymfonyΛଅਐ͢ΔϚΠϯυ
  2. ϑϨʔϜϫʔΫ͸”ίϯϙʔωϯτ”ͷ͋ͭ·Γ composer create-project symfony/skeleton hoge symfony/console symfony/dotenv symfony/framework-bundle symfony/runtime symfony/yaml

    symfony/cache symfony/con fi g symfony/dependency-injection symfony/error-handler symfony/event-dispatcher symfony/http-foundation symfony/http-kernel symfony/poly fi ll-mbstring symfony/ fi lesystem symfony/ fi nder symfony/routing
  3. ϑϨʔϜϫʔΫ͸”ίϯϙʔωϯτ”ͷ͋ͭ·Γ ίϯιʔϧ .env ϑϨʔϜϫʔΫ ϥϯλΠϜ YAMLύʔα Ωϟογϡ੍ޚ ίϯϑΟά DI Τϥʔ੍ޚ

    Πϕϯτ HTTP੍ޚ HTTPΧʔωϧ mbstring֦ு ϑΝΠϧ੍ޚ σΟϨΫτϦ੍ޚ ϧʔςΟϯά composer create-project symfony/skeleton hoge
  4. Πϯετʔϧ௚ޙʹͰ͖Δ͜ͱ͸࠷খݶ -BSBWFM $BLF1)1 4ZNGPOZ $PNNBOE ˓ ˓ ˓ 3PVUJOH ˓

    ˓ ˓ +40/ ˓ ˓ ˓ 5FNQMBUF ˓ ˓ º %# ˓ ˓ º 7BMJEBUJPO ˓ ˓ º .BJM ˓ ˓ º "VUI ˓ ˓ º &WFOU ˓ ˓ ˓ +PC ˓ ˓ º 5FTU ˓ ˓ º
  5. DataMapperͱActiveRecordͷҧ͍ id=1 id=4 id=1 id=4 id=4 id=1 id=1 id=1 id=4

    ࢀর ίϐʔ ૢ࡞ ૢ࡞ ϏδωεϩδοΫ ->save() -> f lush() ஗Ԇ ϑΣον Entity Manager ಉظ ->save() ->save() ίϯτϩʔϥʔ ΫΤϦ͝ͱʹҟͳΔΠϯελϯεੜ੒ɻ ΠϯελϯεʹҰҙੑ͕ͳ͍ɻ != Entity DB ࣮ମ͕ͳ͍ͱ੔߹ੑ͕੒Γཱͨͳ͍ɻ ϏδωεϩδοΫ͕ʮDBอଘʯ੹຿Λ࣋ͭɻ ͢΂ͯͷ Entity ͸Ծ૝తʹΦϯϝϞϦͰ ଍Γͳ͍΋ͷ͚ͩΛ஗ԆϑΣονɻ Repository ͸ࢀরΛఏڙ͢Δ͚ͩɻ ϏδωεϩδοΫ͸OOP͚ͩͰ׬݁͢Δɻ ࠩ෼SQLੜ੒
  6. Test: ֤छςετΛαϙʔτ SymfonyͰ͸ - Unit Test - Integration Test -

    Application Test Λߦ͏؀ڥΛ༻ҙɻ·ͨɺSymfony PantherͰ E2Eςετ΋࣮ࢪՄೳɻ