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

Laravelとドメインモデルと永続化モデル @ laravel.osaka #12

n1215
November 15, 2017

Laravelとドメインモデルと永続化モデル @ laravel.osaka #12

2017/11/15 laravel.osaka#12で使用したスライドです
Laravelと永続化モデルのサンプルコード (Todo管理)
https://github.com/n1215/lara-todo-persistence

n1215

November 15, 2017
Tweet

More Decks by n1215

Other Decks in Programming

Transcript

  1. Domain Driven Development • DDDͰ࡞ΒΕͨOSSͷྫ͕গͳ͍orͳ͍ • →ͱᷖᮣʹൃݴ͢ΔͱSNS্Ͱͭͬ͜·ΕΔ • → Α͘Ͱ͖ͨOSS͸υϝΠϯϞσϧͷ޷ྫͩɺͱ

    → λγΧχ • ͕͔ͩ͠͠ɺ࣮͸൴Β͕஌Γ͍ͨͷ͸DDDͷຊ࣭ ͷ෦෼Ͱ͸ͳ͘ɺΫϦʔϯΞʔΩςΫνϟ΍Ϩϙδ τϦύλʔϯͷ࣮૷ྫͷWebΞϓϦͰ͸ʁ
  2. ύλʔϯ1 Eloquent Model=Entity • هड़ྔతʹ͸΋ͷָ͘͢͝ • EloquentΛ௚ʹ࢖͏ํ๏ͱ΄΅ࠩ͸ͳ͍ • ϨϙδτϦͷ࢓ࣄ΋΄΅ͳ͍ •

    Eloquent Model͕࿐ग़͢ΔͨΊɺυϝΠϯϞσ ϧͷ੹຿֎ͷίʔυΛॻ͖΍͍͢ • ex) $todoItem->save() ͳͲ ←FXCKING!!!! PhpStorm͞Μ΋͓͜
  3. ύλʔϯ2 Entity has Eloquent Model • Eloquent ModelΛ֎෦͔Β৮Βͤͳ͍ ͷͰ1ΑΓ͸ߗ͍ •

    Entity಺෦Ͱ͸ґવͱͯ͠ةݥ͕ͩɺ൓ ໘Eloquentͷػೳͷ׆༻͸͠΍͍͢ • Entityͷ࢓༷มߋׂ͕ͱָ
  4. ύλʔϯ3 POPO Entity and Eloquent Model • POPO = Plain

    Old PHP Object • ΃ͪ͜Μͱ͔ͷൃදͰΑ͘ݟ͔͚Δ • ӬଓԽΛ͸͖ͬΓͱ෼͚Δ • ΤϯςΟςΟͷߏ଄͕Θ͔Γ΍͍͢ • ίʔυͷهड़ྔ͸૿͑·͢
  5. ͦͷଞͷબ୒ࢶ • ӬଓԽϞσϧͱͯ͠EloquentҎ֎Λ࠾༻͢Δέʔε • 4. POPO Entity + ΫΤϦϏϧμʔ •

    →EloquentϞσϧ͕ػೳա৒ؾຯͳͨΊγϯϓϧʹ • 5. POPO Entity + PDO • →4Λಥ͖٧Ίͯ΋͏PDOͰΑ͘Ͷʁͱ͍͏ύλʔϯ • 6. POPO Entity + other DataMapper • → DoctrineͳͲͱࠩ͠ସ͑Δ