Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
CakePHP3レポート
Search
Junkins
May 26, 2016
Technology
0
850
CakePHP3レポート
PHPカンファレンス福岡2016での登壇資料
Junkins
May 26, 2016
Tweet
Share
More Decks by Junkins
See All by Junkins
FusicTechLive1.5 AWSを活かした基幹システムインフラ構成の紹介
junkins
0
65
マルチ〇〇(リージョン、アカウント)の サービスをまとめてみた!
junkins
0
230
[Fukuoka.php Vol.16]LT CakePHP3を使ってみた:Migration Phinxの話
junkins
0
760
Other Decks in Technology
See All in Technology
EKS初心者が早めに知っておきたかったこと
cuorain
0
140
[PyCon Korea 2024] Lightning Talk: PyPI패키지를 의심하세요
studioego
PRO
0
130
グローバル展開を見据えたサービスにおける機械翻訳プラクティス / dp-ai-translating
cyberagentdevelopers
PRO
1
110
キーワードの再整理のススメ ~テストタイプ/テストレベルで最適化!~/20241025 Midori Inada
shift_evolve
0
120
Kubernetes Summit 2024 Keynote:104 在 GitOps 大規模實踐中的甜蜜與苦澀
yaosiang
0
270
Apple/Google/Amazonの決済システムの違いを踏まえた定期購読課金システムの構築 / abema-billing-system
cyberagentdevelopers
PRO
1
190
dbt-coreで実現するCore DataMartsのデータモデリング〜dbt編〜 / Core DataMarts Modeling with dbt-core
i125
3
1.2k
WHOLENESS, REPAIRING, AND TO HAVE FUN: 全体性、修復、そして楽しむこと
snoozer05
PRO
3
3.6k
端末が簡単にリモートから操作されるデモを通じて ソフトウェアサプライチェーン攻撃対策の重要性を理解しよう
kitaji0306
0
150
なんで、私がAWS Heroに!? 〜社外の広い世界に一歩踏み出そう〜
minorun365
PRO
1
540
バイセルにおけるAI活用の取り組みについて紹介します/Generative AI at BuySell Technologies
kyuns
1
200
ABEMA のコンテンツ制作を最適化!生成 AI x クラウド映像編集システム / abema-ai-editor
cyberagentdevelopers
PRO
1
130
Featured
See All Featured
The Pragmatic Product Professional
lauravandoore
31
6.3k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
106
49k
Practical Orchestrator
shlominoach
186
10k
What's new in Ruby 2.0
geeforr
342
31k
Typedesign – Prime Four
hannesfritz
39
2.4k
Raft: Consensus for Rubyists
vanstee
136
6.6k
Designing the Hi-DPI Web
ddemaree
280
34k
The Power of CSS Pseudo Elements
geoffreycrofte
72
5.3k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
32
1.8k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
22k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Transcript
CakePHP3Ϩϙʔτ 2016/05/21 PHPΧϯϑΝϨϯεԬ ҏ౻ ५थ
Introduction ҏ౻ ५थ Junkins_110 Junkins 1.3 2.ʙ 3.ʙ
Agenda CakePHP3 Ϩϙʔτ ࣮ࡍʹҊ݅Ͱ࠾༻ͨ͠ॴײ (ྑ͔ͬͨͱ͜Ζɺѱ͔ͬͨͱ͜Ζ) Model ( TableɺEntity ) 1.
EntityͬͯԿʁ 2. Entityศརͩͬͨʁ 3. EntityͰϋϚͬͨͱ͜Ζ͋ͬͨʁ ࠓ·Ͱ$BLF1)1Λ͍ͬͯͯɺ͜Ε͔Β$BLF1)1Λ͏ํ͚ CakePHP2ͱͷൺֱ͕ͪΐͪ͜ΐ͜ɻɻɻɻ
1. EntityͬͯԿʁ 1. What is Entity?
1. EntityͬͯԿʁ 1-1. MVC 1-2. TableͱEntity 1-3. Entityͷొγʔϯ 1. What
is Entity?
1. What is Entity? V C M MVC Model View
Controller View Controller Model
1. What is Entity? MVC Model View Controller V C
M View Controller Model
1. What is Entity? V C M CakePHP2 MVC of
CakePHP2
1. What is Entity? V C T CakePHP3 E Table
Entity MVC of CakePHP3
T 1. What is Entity? E ɾ$BLF1)1ͷʮ.PEFMʯʹׂ͍ۙ Table Entity ɾ%#ͷʮ5BCMFʯͷΞΫηε
ɾσʔλϨίʔυ TableͱEntity ɾϨίʔυ͝ͱʹΠϯελϯεԽ ɾྻͰͳ͍ͷͰ֦ு͕༰қ ɾ7BMJEBUJPO Associationͷઃఆ
1. What is Entity? E Entityͷొγʔϯ E E E E
E E E E E E E E E E E E E E E E E E E E E Ma Request Data DB ResultSet Marshaller beforeMarshal() Validation() SELECT SELECT
1. EntityͬͯԿʁ EntityCakePHP2Ͱ͍͏ModelͷҰ෦ CakePHP2ͷModelTableͱEntityʹ͔Εͨ find(SELECT)ͨ͠ͱ͖ + POST͞Εͨͱ͖ POST͞ΕͨσʔλΛEntityԽ͢Δͱ͖ʹόϦσʔγϣϯ͕ಈ͘ ( CakePHP2ͱಉ༷ʹอଘ࣌ʹόϦσʔγϣϯಈ͘
) 1. What is Entity?
2. Entityศརͩͬͨʁ 2. Is Entity useful ?
2. Is Entity useful ? 2. Entityศརͩͬͨʁ 2-1. ॲཧ͕؆ܿʹͳͬͨ ɾFat
Controller -> Fat Model -> ? 2-2. GetterͱSetter ɾ.7$ͷͲ͔͜ΒͰΞΫηεՄೳ
V C M Fat Controller ॳ৺ऀͷ͜Ζ 2. Is Entity useful
?
V C M Fat Model খ׳Ε͖ͯͨ͜Ζ 2. Is Entity useful
?
V C M T E Finder Validation Association Save 2.
Is Entity useful ? ͜ͷ͝Ζ μΠΤοτ
V C M T E μΠΤοτ Finder Validation Association Save
2. Is Entity useful ? ͜ͷ͝Ζ
2. Is Entity useful ? V C M E CakePHP3
E E E function hoge() V C M CakePHP2 V C M array( ) array( ) array( ) function hoge() Ͳ͔͜ΒͰΞΫηε
2. Is Entity useful ? V C M E Ͳ͔͜ΒͰΞΫηε
CakePHP3 E E E function hoge() V C M CakePHP2 V C M array( ) array( ) array( ) function hoge() hoge() hoge() hoge()
2. Is Entity useful ? V C M E CakePHP3
E E E function hoge() V C M CakePHP2 V C M array( ) array( ) array( ) function hoge() hoge() hoge() Ͳ͔͜ΒͰΞΫηε
2. Is Entity useful ? Getter ྫ) ͱ໊Λͭͳ͛ͯग़ྗ ̎ͭͷϑΟʔϧυΛͭͳ͛ͯग़ྗ ϑΟʔϧυʹॲཧΛՃ͑ͯग़ྗ
ྫ) ֹۚΛ੫ࠐʹ ※ CakePHP2ͷafterFind()͕ෆཁʹͳΔ
2. Is Entity useful ? Setter ྫ) อଘ࣌ͷύεϫʔυΛϋογϡԽ ྫ) ੜ݄ͷอଘͱಉ࣌ʹྸอଘ
อଘ͢Δલͷͷมߋ ผϑΟʔϧυͷͷՃ ※ CakePHP2ͷbeforeSave()ͷهड़͕ݮΔ
2. Is Entity useful ? 2. Entityศརͩͬͨʁ 1Ϋϥε͋ͨΓͷهड़ྔ͕ݮͬͨ ViewͰͷԋࢉࢠͷྔ͕ݮͬͨ ModelͷίʔϧόοΫͷهड़ྔ͕ݮͬͨ
Fat EntityʹͳΒͳ͍ͨΊͷTips ڞ௨ॲཧ5SBJUԽʂ
3. EntityͰϋϚͬͨͱ͜Ζ͋ͬͨʁ
3. EntityͰϋϚͬͨͱ͜Ζ͋ͬͨʁ 1. อଘ࣌ʹ(FUUFS͕Δ 2. ෳճ4FUUFS͕Δ
3-1.อଘ࣌ʹ(FUUFS͕Δ ঢ়گ) ֹۚΛද͍ࣔͨ͠ʂJOQVUͷΧϯϚ۠Γʹ͍ͨ͠ʂ 1000 int text 1,000 text 1,000 1000
int 1000 int text 1,000 1000 int text1,000 text 1,000 1000 int Getter Setter Getter Setter Getter ཧ ݱ࣮ SQL Error ※ ΧϥϜ໊Ͱ(FUUFSΛ࡞͢Δ࣌ҙ
3-2.ෳճ4FUUFS͕Δ ঢ়گ) ϚϧνεςοϓͷϑΥʔϜΛ࡞Γ͍ͨ Request Data Ma Form1 Form2 _setPassword() E
adminadmin dsfknadfgnadflgkng Request Data Ma _setPassword() E dsfknadfgnadflgkng 32ekwnesihwenfansrueaf ͋Εʁ ※EntityͷઃఆΛมߋ͢Ε͍͍͕ɺ ɹɹ Marsherӽ͠ͰઃఆΛมߋͰ͖ͳ͍
3. EntityͰϋϚͬͨͱ͜Ζ͋ͬͨʁ ҙਤ͍ͯ͠ͳ͍λΠϛϯάͰॲཧ͕Δ Entityͷઃఆ৮Γʹ͍͘ EntityҎ֎ͷ෦ͷམͱ݀͋͠·Γͳ͍
·ͱΊ EntityΛ͍͜ͳͤΕɺޮతͳ։ൃ͕Մೳ TableɺEntity͕͔Εͯɺඇৗʹॻ͖͍͢ EntityඇৗʹศརͰCakePHP3Λ͏ͳΒੋඇཧղͯ͠΄͍͠ Entityศརͳɺཧղͯ͠Θͳ͍ͱམͱ͕݀͋͠Γ·͢ PluginΛ࡞Δͱ͖Entityͷಈ͖ʹؾΛ͚ͭͳ͍ͱ͍͚ͳ͍
͍͞͝ʹ FusicςΫϊϩδʔ͕ ͖ͳΤϯδχΞΛืू͍ͯ͠·͢ https://fusic.github.io
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ