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

CakePHP3レポート

 CakePHP3レポート

PHPカンファレンス福岡2016での登壇資料

Junkins

May 26, 2016
Tweet

More Decks by Junkins

Other Decks in Technology

Transcript

  1. Agenda CakePHP3 Ϩϙʔτ ࣮ࡍʹҊ݅Ͱ࠾༻ͨ͠ॴײ (ྑ͔ͬͨͱ͜Ζɺѱ͔ͬͨͱ͜Ζ) Model ( TableɺEntity ) 1.

    EntityͬͯԿʁ 2. Entity͸ศརͩͬͨʁ 3. EntityͰϋϚͬͨͱ͜Ζ͋ͬͨʁ ࠓ·Ͱ$BLF1)1Λ࢖͍ͬͯͯɺ͜Ε͔Β$BLF1)1Λ࢖͏ํ޲͚ CakePHP2ͱͷൺֱ͕ͪΐͪ͜ΐ͜ɻɻɻɻ
  2. 1. What is Entity? V C M MVC Model View

    Controller View Controller Model
  3. T 1. What is Entity? E ɾ$BLF1)1ͷʮ.PEFMʯʹ͍ۙ໾ׂ Table Entity ɾ%#ͷʮ5BCMFʯ΁ͷΞΫηε

    ɾσʔλϨίʔυ TableͱEntity ɾϨίʔυ͝ͱʹΠϯελϯεԽ ɾ഑ྻͰ͸ͳ͍ͷͰ֦ு͕༰қ ɾ7BMJEBUJPO Associationͷઃఆ
  4. 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
  5. 2. Is Entity useful ? 2. Entity͸ศརͩͬͨʁ 2-1. ॲཧ͕؆ܿʹͳͬͨ ɾFat

    Controller -> Fat Model -> ? 2-2. GetterͱSetter ɾ.7$ͷͲ͔͜ΒͰ΋ΞΫηεՄೳ
  6. V C M T E Finder Validation Association Save 2.

    Is Entity useful ? ͜ͷ͝Ζ μΠΤοτ
  7. 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() Ͳ͔͜ΒͰ΋ΞΫηε
  8. 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()
  9. 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() Ͳ͔͜ΒͰ΋ΞΫηε
  10. 2. Is Entity useful ? Setter ྫ) อଘ࣌ͷύεϫʔυΛϋογϡԽ ྫ) ੜ೥݄೔ͷอଘͱಉ࣌ʹ೥ྸ΋อଘ

    อଘ͢Δલͷ஋ͷมߋ ผϑΟʔϧυ΁ͷ஋ͷ௥Ճ ※ CakePHP2ͷbeforeSave()ͷهड़͕ݮΔ
  11. 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Λ࡞੒͢Δ࣌͸஫ҙ
  12. 3-2.ෳ਺ճ4FUUFS͕૸Δ ঢ়گ) ϚϧνεςοϓͷϑΥʔϜΛ࡞Γ͍ͨ Request Data Ma Form1 Form2 _setPassword() E

    adminadmin dsfknadfgnadflgkng Request Data Ma _setPassword() E dsfknadfgnadflgkng 32ekwnesihwenfansrueaf ͋Εʁ ※EntityͷઃఆΛมߋ͢Ε͹͍͍͕ɺ ɹɹ Marsherӽ͠Ͱ͸ઃఆΛมߋͰ͖ͳ͍