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
66
マルチ〇〇(リージョン、アカウント)の サービスをまとめてみた!
junkins
0
230
[Fukuoka.php Vol.16]LT CakePHP3を使ってみた:Migration Phinxの話
junkins
0
760
Other Decks in Technology
See All in Technology
New Relicを活用したSREの最初のステップ / NRUG OKINAWA VOL.3
isaoshimizu
2
570
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
570
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
Platform Engineering for Software Developers and Architects
syntasso
1
510
Why does continuous profiling matter to developers? #appdevelopercon
salaboy
0
180
サイバーセキュリティと認知バイアス:対策の隙を埋める心理学的アプローチ
shumei_ito
0
380
開発生産性を上げながらビジネスも30倍成長させてきたチームの姿
kamina_zzz
2
1.7k
The Role of Developer Relations in AI Product Success.
giftojabu1
0
120
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
860
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
150
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
Featured
See All Featured
A designer walks into a library…
pauljervisheath
203
24k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
Building an army of robots
kneath
302
43k
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
665
120k
Facilitating Awesome Meetings
lara
50
6.1k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Done Done
chrislema
181
16k
Scaling GitHub
holman
458
140k
Build your cross-platform service in a week with App Engine
jlugia
229
18k
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
27
4.3k
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
͋Γ͕ͱ͏͍͟͝·ͨ͠ʂ