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

今すぐできるLaravelフレームワーク!~業務アプリ開発~

 今すぐできるLaravelフレームワーク!~業務アプリ開発~

PHPカンファレンス関西2017@大阪グランフロントでの発表スライドです

Takehiko Sakamoto

July 13, 2017
Tweet

More Decks by Takehiko Sakamoto

Other Decks in Programming

Transcript









































  1. ͙͢෼͔ΔʂLaravel ۀ຿ΞϓϦ։ൃร
    ࡔຊ߶඙ @sakamoto03
    גࣜձࣾισΟ
    οΫ
    PHP ΧϯϑΝϨϯε ؔ੢ 2017/07/15 @ άϥϯυϑϩϯτେࡕ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 1 / 41

    View full-size slide









































  2. Speacker Introduction
    ձࣾ גࣜձࣾισΟ
    οΫ
    ػց޻ۀ 3D ϓϦϯλʔ΍ίϯϏχ޲͚੡໙ػ΍์ిՃ޻ػΛ։ൃ
    ෦ॺ ৘ใηΩϡϦςΟ΍άϩʔόϧΨόφϯε޲͚ IT ౤ࢿ੝Μ
    ৬छ ࣾ಺ SE
    ࢓ࣄ PHP, JQuery, React, Bootstrap, Nginx@ࣾ಺γεςϜ։ൃ
    ࡶ༻ ύιίϯɺλϒϨοτઃఆ
    ؔ৺ Re-Engineering Legacy Code, Software Testing
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 2 / 41

    View full-size slide









































  3. ισΟ
    οΫ Ճլࣄۀॴ
    ॅॴ ੴ઒ݝՃլࢢٶொྗ̍ʔ̍ (ຊࣾɿԣ඿)
    ৿ࢁւԹઘ
    ޻৔
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 3 / 41

    View full-size slide









































  4. Today’s Outline
    1
    ʮLaravelͬͯԿʁʯΛ Laravel ͷࢥ૝͔ΒಡΈղ͘
    2 Laravel Ͱ࡞ΔΞϓϦͷλʔήοτઃఆ
    3 Laravel Validation ͷղઆ
    Validation ͱ͸ʁ
    Laravel Validation @ PHP
    Rails Validation @ Ruby
    Spring Validation @ Java
    Angular Validation @ Javascript
    CakePHP Validation @ PHP
    4 Closing
    1
    ⃝͕݁࿦ɺ 2
    ⃝ɺ 3
    ⃝͸ 1
    ⃝Λαϙʔτ͢ΔͨΊʹ͋Γ·͢
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 4 / 41

    View full-size slide









































  5. What’s Laravel?
    Laravel ެࣜαΠτͷτοϓϖʔδΑΓ
    Love beautiful code? We do too.
    The PHP Framework For Web Artisans.
    URL : https ://laravel.com/
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 5 / 41

    View full-size slide









































  6. What’s the (Web) Artisan?
    ҙຯ
    Artisan ʲ໊ࢺʳ[৬ਓɺঊ]
    Artʲ໊ࢺʳ[ܳज़]
    ৽૷൛ ୡਓϓϩάϥϚʔ ৬ਓ͔Β໊ঊ΁ͷಓ P13 ΑΓ
    ஶऀ :Andrew Hunt, David Thomas ൃച೔ : 2016/10 ຊମ 3,200 ԁʴ੫
    c
    ⃝ohmsha
    ൈਮ ͍͔ͭ͘ͷ఺ʹ͓͍ͯɺϓϩάϥϛϯά͸ֆըͱΑ͘ࣅ
    ͍ͯ·͢ɻ
    ࠷ॳʹɺਅͬനͳΩϟϯόεͱجຊతͳૉࡐΛ༻ҙ͠
    ·͢ɻ
    ͦͯ͠ɺ໨తʹԠͯ͡ɺ
    ૉࡐʹՊֶɺܳज़ɺٕܳΛ૊Έ߹Θ͍ͤͯ͘ͷͰ͢ɻ
    ղऍ Computer Science + Art + IT Technique = Programming
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 6 / 41

    View full-size slide









































  7. The Relationship between Art and Architecture
    Art ʹؔ࿈ͨ͠਎ۙͳ IT ༻ޠ
    Artʲ໊ࢺʳ[ܳज़]
    Architectureʲ໊ࢺʳ[ݐங༷ࣜɺ৘ใγεςϜͷઃܭํ๏ɾࢥ૝]
    จԽͷ຋༁ʔҏ౻஧ଠͷࣦഊʔ @ http ://www.kamit.jp/16 ʊ essay/bunka.htm c
    ⃝ਆ୩෢෉
    ൈਮ
    ӳޠͰ͸ ʡ
    Architecture ʡ
    ͕͓΋ʹ૊߹ͤ͞Δ૬ख͸
    ʡ
    Art ʡ
    Ͱ͋ͬͯɺArt and Architecture ʡ
    ͱ͍͏۟͸
    ͻΜͺΜʹ͓໨ʹ͔͔Δɻ
    ֆը΍ூࠁͳͲͷඒज़ͱݐஙͱΛ͘͘Δݴ༿͔ͩΒɺ
    ͜Ε͸ʮඒज़ɺݐஙʯͱ༁͢ΑΓ΋
    ʮ଄ܗܳज़ʯͱ͍͏༁ޠ͕ద౰͔΋͠Εͳ͍ɻ
    ղऍ ͱ͍͏͜ͱ͸ɺ࣮͸৘ใγεςϜ΋ܳज़తݐங෺
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 7 / 41

    View full-size slide









































  8. Laravel (Basic) Spirits @ https ://laravel.com
    Expressive, beautiful syntax.
    Value elegance, simplicity, and readability? You’ll fit right in. Laravel is
    designed for people just like. If you need help getting started, check out
    Laracasts and our great documentation.
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 8 / 41

    View full-size slide









































  9. Laravel 4.2 Introduction https ://laravel.com/docs/4.2/introduction
    Laravel Philosophy (ࢥ૝)
    Laravel is a web application framework with expressive, elegant syntax.
    We believe development must be an enjoyable, creative experience to be
    truly fulfilling.
    Laravel attempts to take the pain out of development by easing common
    tasks used in the majority of web projects, such as authentication, routing,
    sessions, and caching.
    Expressive(දݱʹ෋Έ) +
    Elegant(؆ܿʹɺ͖ͬ͢Γ) ϓϩάϥϜ͕ॻ͚ͯ +
    Enjoyable(ָ͘͠) +
    Creative(૑଄తˍಠ૑తʹ) ͳ࢓ࣄ === Development(։ൃ)
    by Laravel
    Expressive + Elegant + Enjyoable + Creative = Artisan
    3E + 1C ͳ΢Σϒ։ൃΛ Laravel Ͱͯ͠Έ·ͤΜ͔ʁ
    Expressive + Elegant + Enjyoable + Creative = 3E + 1C
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 9 / 41

    View full-size slide









































  10. ͳͥɺ3E+1C ͳ։ൃ͕Ͱ͖Δͷ͔ʁ
    Laravel Philosophy (ࢥ૝) https ://laravel.com/docs/4.2/introduction
    Laravel is a web application framework with expressive, elegant syntax.
    We believe development must be an enjoyable, creative experience to be
    truly fulfilling.
    Laravel attempts to take the pain out of development by easing common
    tasks used in the majority of web projects, such as authentication, routing,
    sessions, and caching.
    ຖճॻ͘Α͏ͳڞ௨ػೳΛ؆ૉԽ (Easy) ͍ͯ͠Δ
    ͦͷͨΊɺશମΛߏ੒͢Δ͜ͱʹ࣌ؒΛ͚͞Δ
    ΞʔΩςΫνϟʹઐ೦Ͱ͖Δ
    ޙपΓʹͳΓ͕ͪͳ࡞ۀͷ࣌ؒ֬อ
    Software Design, Refactoring, Testing, Documentation
    Artisan = Art = Architecture
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 10 / 41

    View full-size slide









































  11. ͓୊ɿLaravel ͰԿΛ࡞Γ·͔͢ʁ
    ఏҊʢখ੠ʣ
    Laravel Ͱ (খن໛Ͱ௒஍ຯͳ) ۀ຿ΞϓϦ࡞ͬͯΈ·ͤΜ͔ʁ
    Laravel Ͱएऀʹਓؾͷग़ͦ͏ͳ
    ०ͷେن໛ SNS ΢ΣϒΞϓϦΛ
    ࠓͲ͖ͳײ͡Ͱ AWS ্Ͱ࡞ͬͯΈ·ͤΜ͔ʁ
    File Storage : Amazon S3
    Notifications : Slack
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 11 / 41

    View full-size slide









































  12. ۀ຿ΞϓϦέʔγϣϯͬͯԿʁ
    ੜ࢈؅ཧɺࡏݿ؅ཧɺൢച؅ཧ౳ͷγεςϜ
    େاۀ޲ۀ຿ΞϓϦέʔγϣϯ
    SAP
    ORACLE ERP
    தݎˍதখاۀ޲ۀ຿ΞϓϦέʔγϣϯ
    FUJITSU GLOVIA
    NEC EXPLANNER
    ຊηογϣϯதͰͷۀ຿ΞϓϦͷΠϝʔδɾҐஔ͚ͮ
    ༷ʑͳ৘ใΛʮೖྗ͍ͯ͘͠ελΠϧʯͷ৘ใ౷߹ΞϓϦ
    ೖྗ৘ใʹϏδωεΠϯϑΥϝʔγϣϯɾۀ຿৘ใ
    ᄁ͖΍νϥཪ΍೔هͳͲιʔγϟϧΠϯϑΥϝʔγϣϯ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 12 / 41

    View full-size slide









































  13. ϦΞϧۀ຿ΞϓϦ
    SAP ͷೖྗը໘ 1 ը໘Ͱ༷ʑͳೖྗ͕৘ใ͕ೖྗՄೳˍू໿Մೳ c
    ⃝SAP
    Զ͕ΨϯμϜͩ ͜Ε͕ۀ຿ΞϓϦͩ cv. ႢಹɾFɾηΠΤΠʢٶ໺ਅकʣ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 13 / 41

    View full-size slide









































  14. ϦΞϧۀ຿ΞϓϦͷޫͱҋ
    ϝϦοτ
    ৘ใ͕ू໿ɾ౷߹͞Εɺ৘ใͷಡΈख͸༷ʑͳࢹ఺ͰΈΕΔ
    σϝϦοτ
    ೖྗۀ຿ͷ૿େԽ͠ɺෳࡶԽΛ΋ͨΒ͢
    άϩʔόϧԽɾࠃࡍԽʹΑΓɺෳࡶ͞͸૿͢Ұํ
    ೖྗϛε͕ൃੜ͢Δ
    λΠϓϛεʗදهϛεʗදه༳Εʗೖྗऀؒͷࢥ૝ͷҧ͍
    ͜ͷೖྗϛεΛ๷͍͗ͨɾ્ࢭ͍ͨ͠ ˠ ҋΛޫ΁
    ೖྗϛεͷ๷ࢭ͢Δͷ͕ Validation ػೳ
    ͜ͷػೳ͕ڧ͚Ε͹ɺڧ͍΄Ͳۀ຿ΞϓϦͷҋΛফͤΔ
    Laravel ͷ Validation ػೳ͕༏Ε͍ͯΔͱ͍͏஡൪ܶ։ນφ΢
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 14 / 41

    View full-size slide









































  15. Intermission ......
    1 PHP Laravel Validation
    2 Ruby on Rails Validation
    3 Java Spring Framework Validation
    4 Javascript Angular Validation
    5 PHP CakePHP Validation
    Laravel ͱͷࠩҟΛײ͡ͱͬͯԼ͍͞
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 15 / 41

    View full-size slide









































  16. Validation ͱ͸ʁ
    Ұൠ IT ༻ޠ ೖྗ͞Εͨσʔλ͕γεςϜͷ࢓༷ʹ͍ͦͬͯΔ͔Ͳ͏͔ݕূ
    Web ্ ೖྗϑΟʔϧυ͕ೖྗϧʔϧʹ͍ͦͬͯΔ͔Ͳ͏͔ݕূ
    ྫɿϧʔϧʹ൓͍ͯ͠ΔͳΒܹ͓͜੺৭ϝοηʔδΛදࣔ
    ྫɿೖྗҧ൓ͳΒॲཧΛ͠ͳ͍ɺ࣍ͷॲཧ΁ߦ͔ͳ͍
    c
    ⃝google
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 16 / 41

    View full-size slide









































  17. Laravel Spirits for Validation
    ͜ͷϧʔϧΛ؆ܿʹ (Elegant) ؆୯ʹ (Easy) ϓϩάϥϜͰදݱͰ͖
    Δ (Expressive) ͷ͕ Laravel
    Ͱ͸ɺElegant ʹ Easy ʹ Expressive ʹ Validation Λॻ͖·͠ΐ͏ʂ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 17 / 41

    View full-size slide









































  18. Laravel Validation @ https ://laravel.com/docs/5.4/validation
    /∗∗
    ∗ Store a new blog post .

    ∗ @param Request $request
    ∗ @return Response
    ∗/
    public function store ( Request $request )
    {
    $this −>v a l id at e ( $request , [
    ’ t i t l e ’ => ’ required | unique : posts |max:255 ’ ,
    ’ body ’ => ’ required ’ ,
    ] ) ;
    / / The blog post i s valid , store in datebase
    }
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 18 / 41

    View full-size slide









































  19. Laravel Validation@ https ://laravel.com/docs/5.4/validation
    /∗∗
    ∗ Store a new Google account .
    ∗ @param Request $request
    ∗ @return Response
    ∗/
    public function store ( Request $request )
    {
    $this −>v a l id a t e ( $request , [
    ’LastName ’ => ’ required ’ ,
    ’ FirstName ’ => ’ required ’ ,
    ’ GmalAddress ’ => ’ required ’ ,
    ’Passwd ’ => ’ required | min : 8 ’ ,
    ’ PasswdAgain ’ => ’ required | min :8 ,
    . . . ] ) ;
    / / The post i s valid , store in DB
    }
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 19 / 41

    View full-size slide









































  20. Active Record Validation @ RAILS GUIDES
    https ://railsguides.jp/active_record_vlidations.html
    class Person < ActiveRecord : : Base
    validates : name, presence : true
    end
    Person . create (name: " John Doe " ) . v a l i d ? # => true
    Person . create (name: n i l ) . v a l i d ? # => false
    ެࣜղઆ ͜ͷόϦσʔγϣϯͰ͸ Person ʹ name ଐੑ͕ͳ͍৔߹ʹ
    ແޮͰ͋Δ͜ͱΛ஌Βͤ·͢ɻ
    @Laravel ’name’ => ’present’
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 20 / 41

    View full-size slide









































  21. Active Record Validation @ RAILS GUIDES
    https ://railsguides.jp/active_record_vlidations.html
    class Topic < ActiveRecord : : Base
    validates :name, presence : true , length : { minimum : 3}
    end
    @Laravel ’name’ => ’present|min :3’
    Code Semantics Ωʔ͕ೖྗϑΟʔϧυɺόϦϡʔ͕ೖྗϧʔϧ˕
    @Rails validates : name
    ,presence :true
    ,length : minimum : 3
    Code Semantics ࠷ॳͷΧϯϚͱ̎൪໨ͷΧϯϚͷίʔυͷҙຯ͸ಉ
    ͔͡ʁ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 21 / 41

    View full-size slide









































  22. spring Validaing Form Input @ https ://spring.io/guides/gs/validating-form-input/
    package hello ;
    import javax . v a l i d a t i o n . constraints . Min ;
    import javax . v a l i d a t i o n . constraints . NotNull ;
    import javax . v a l i d a t i o n . constraints . Size ;
    public class PersonForm {
    @NotNull
    @Size( min=2 , max=30)
    pri vat e String name;
    @NotNull
    @Min(18)
    pri vat e Integer age ;
    public String getName ( ) {
    return t h i s .name;
    }
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 22 / 41

    View full-size slide









































  23. Spring Validaing Form Input @ https ://spring.io/guides/gs/validating-form-input/
    Java Annotation
    import javax . v a l i d a t i o n . constraints . Min ;
    import javax . v a l i d a t i o n . constraints . NotNull ;
    import javax . v a l i d a t i o n . constraints . Size ;
    public class PersonForm {
    @NotNull
    @Size( min=2 , max=30)
    priv ate String name;
    @NotNull
    @Min(18)
    priv ate Integer age ;
    @Spring Annotation Λ༻͍ͯهड़
    @Laravel ’name’ => ’required|min :2|max :30’,
    ’age’ => ’required|numeric|min :18’,
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 23 / 41

    View full-size slide









































  24. ANGULAR Form Validation @ https ://angular.io/guide/gs/validation
    < label f o r ="name">Name label >
    required minlength ="4" maxlength ="24"
    name="name" [ ( ngModel ) ] = " hero .name"
    #name="ngModel">
    class =" a l e r t a l e r t −danger">

    Name i s required
    div >

    Name must be least 4 characters long .
    div >

    Name cannot be more than 24 characters long .
    div >
    div >
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 24 / 41

    View full-size slide









































  25. ANGULAR Form Validation @ https ://angular.io/guide/gs/validation
    < label f o r ="name">Name label >
    required minlength ="4" maxlength ="24"
    name="name" [ ( ngModel ) ] = " hero .name"
    #name="ngModel">
    @Laravel ’name’ => ’required|min :4|max :24’
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 25 / 41

    View full-size slide









































  26. ANGULAR Form Validation @ https ://angular.io/guide/gs/validation


    Name i s required
    div >

    Name must be least 4 characters long .
    div >

    Name cannot be more than 24 characters long . div > . . .
    @Laravel Customizing The Error Messages
    public function messages ( )
    {
    return [
    ’name. required ’ => ’Name i s required ’ ,
    ’name. min ’ => ’Name must be least 4 characters long ’ ,
    ’name.max ’ => ’Name cannot be more than 24 characters ’ ,
    ] ;
    }
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 26 / 41

    View full-size slide









































  27. ANGULAR Form Validation @ https ://angular.io/guide/gs/validation


    Name i s required
    div >

    Name must be least 4 characters long .
    div >

    Name cannot be more than 24 characters long . div > . . .
    @Laravel Custom Error Messages
    $messages = [
    ’name. required ’ => ’Name i s required ’ ,
    ’name. min ’ => ’Name must be least 4 characters long ’ ,
    ’name.max ’ => ’Name cannot be more than 24 characters ’ ,
    ] ;
    $ v a l i d a t o r = Validator : : make( $input , $rules , $messages ) ;
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 27 / 41

    View full-size slide









































  28. ANGULAR Form Validation @ https ://angular.io/guide/gs/validation


    Name i s required
    div >

    Name must be least 4 characters long .
    div >

    Name cannot be more than 24 characters long . div > . . .
    @Laravel Specifying Custom Message In Language Files
    resources/lang/en/validation.php
    ’ custom ’ => [
    ’name ’ => [
    ’ required ’ => ’Name i s required ’ ,
    ’ min ’ => ’Name must be least 4 characters long ’ ,
    ’max ’ => ’Name cannot be more than 24 characters ’ ,
    ] ,
    ] ,
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 28 / 41

    View full-size slide









































  29. CakePHP Core Validation Rules @
    https ://book.cakephp.org/3.0/en/core-libraries/validation.html
    $ v a l i d a t o r = new Validator ( ) ;
    $ v a l i d a t o r
    −>add ( ’ t i t l e ’ , ’ minLength ’ , [
    ’ rule ’ => [ ’ minLength ’ , 10]
    ] )
    −>add ( ’ rating ’ , ’ validValue ’ , [
    ’ rule ’ => [ ’ range ’ , 1 , 5]
    ] ) ;
    @Laravel
    $this −>v a l i d a t e ( $request , [
    ’ t i t l e ’ => ’ min :10 ’ ,
    ’ rating ’ => ’ between :1 ,5 ’ ,
    ] ) ;
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 29 / 41

    View full-size slide









































  30. CakePHP Core Validation Rules @
    https ://book.cakephp.org/3.0/en/core-libraries/validation.html
    $ v a l i d a t o r = new Validator ( ) ;
    $ v a l i d a t o r
    −>add ( ’ t i t l e ’ , ’ minLength ’ , [
    ’ rule ’ => [ ’ minLength ’ , 10]
    ] )
    −>add ( ’ rating ’ , ’ validValue ’ , [
    ’ rule ’ => [ ’ range ’ , 1 , 5]
    ] ) ;
    @Laravel
    $ v a l i d a t o r = Validator : : make( $request −> a l l ( ) , [
    ’ t i t l e ’ => ’ min :10 ’ ,
    ’ rating ’ => ’ between :1 ,5 ’ ,
    ] ) ;
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 30 / 41

    View full-size slide









































  31. CakePHP Validation @ https ://book.cakephp.org/3.0/en/core-libraries/validation.html
    $ v a l i d a t o r
    −>requirePresence ( ’ t i t l e ’ )
    −>notEmpty ( ’ t i t l e ’ , ’ Please f i l l t h i s f i e l d ’ )
    −>add ( ’ t i t l e ’ , [
    ’ length ’ => [
    ’ rule ’ => [ ’ minLength ’ , 10] ,
    ’message ’ => ’ T i t l e s need to be
    at least 10 characters long ’ ,
    ]
    ] ) ;
    @Laravel
    @validate part
    ’ t i t l e ’ => ’ present | required | min :10 ’
    @messeage part
    ’ t i t l e . required ’ => ’ Please f i l l t h i s f i e l d ’
    ’ t i t l e . min ’ => ’ T i t l e s need to be
    at least 10 characters long ’
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 31 / 41

    View full-size slide









































  32. CakePHP Validation @
    https ://book.cakephp.org/3.0/en/core-libraries/validation.html
    $ v a l i d a t o r
    −>requirePresence ( ’ t i t l e ’ )
    −>notEmpty ( ’ t i t l e ’ , ’ Please f i l l t h i s f i e l d ’ )
    −>add ( ’ t i t l e ’ , [
    ’ length ’ => [
    ’ rule ’ => [ ’ minLength ’ , 10] ,
    ’message ’ => ’ T i t l e s need to be
    at least 10 characters long ’ ,
    ]
    ] )
    −>allowEmpty ( ’ published ’ )
    −>add ( ’ published ’ , ’ boolean ’ , [
    ’ rule ’ => ’ boolean ’ ] )
    −>requirePresense ( ’ body ’ )
    −>add ( ’ body ’ , ’ length ’ , [
    ’ rule ’ => [ ’ minLength ’ , 50] ,
    ’message ’ => ’ A r t i c l e s must have a s u b s t a n t i a l
    body . ’ ] ) ;
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 32 / 41

    View full-size slide









































  33. CakePHP Validation ͱ Laravel Validation ͷҧ͍
    @CakePHP ॎͷԆͼΔϧʔϧ
    @Laravel ԣʹԆͼΔϧʔϧ
    ’title’ => ’required|unique :posts|max :255’,
    @CakePHP rule ͱ message ͕Ұॹ
    @Laravel rule ͱ message ͕෼཭
    ϧʔϧ͕ଟ͘ͳͬͨ࣌ʹՄಡੑΛҡ࣋Ͱ͖Δͷ͸ Laravel
    ۀ຿ΞϓϦ͸ೖྗ߲໨͕ଟ͍ͷͰϧʔϧ΋ඞવతʹଟ͘ͳΔ
    ͔ͩΒ Laravel
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 33 / 41

    View full-size slide









































  34. How about Laravel Validation?
    if( Laravel > (Rails|Spring|Angular|CakePHP) )
    ...
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 34 / 41

    View full-size slide









































  35. Available Laravel Validation Rules
    Accepted Dimensions(Image Files) Numeric
    Active URL Distinct Present
    After(Date) E-Mail Regular Expression
    After Or Equal (Date) Exists (Database) Required
    Alpha File Required If
    Alpha Dash Filled Required Unless
    Alpha Numeric Image (File) Required With
    Array In Required With All
    Before(Date) In Array Required Without
    Before Or Equal(Date) Integer Required Without
    Between IP Address Same
    Boolean JSON Size
    Confirmed Max String
    Date MIME Types Timezone
    Date Format MIME Type By File Extension Unique (Database)
    Different Min URL
    Digits Nullable
    Digits Between Not in
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 35 / 41

    View full-size slide









































  36. Closing
    Expressive + Elegant + Enjyoable + Creative Worker = Developer =
    Artisan
    IT ઓ͔࢜Β (3E+1C ͳ)IT ۛ༡ࢻਓʹδϣϒνΣϯδ
    ——–>
    Validation ͸ۀ຿ΞϓϦͰॏཁͳΜͰ͢ʂ
    Laravel Validation > Other Validation
    Laravel ࢖Θͳ͖Όଛ͡ΌͶʁ
    Laravel ͍ͭ΍Δ͔ʁ ࠓͰ͠ΐʂ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 36 / 41

    View full-size slide









































  37. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 37 / 41

    View full-size slide









































  38. ิ଍ࢿྉ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 38 / 41

    View full-size slide









































  39. ϦΞϧۀ຿ΞϓϦέʔγϣϯಋೖޙͷ՝୊
    Example
    ಋೖޙͷ໰୊఺
    ൚༻੡඼ͳͷͰػೳ໘Ͱ༥௨͕ޮ͖ʹ͍͘ɻ੡඼ಠࣗͷࢥ૝͕͋Δɻ
    ೖྗσʔλͳͲΛ༰қʹ͸ফͤͳ͍౳ɻ
    গ͠Ͱ΋༥௨Λޮ͔ͤΑ͏ͱ͢ΔͷͳΒ͹ɺ੡඼ʹରͯ͠ΧελϚ
    Πζ͕ඞཁ
    ୠ͠ɺ੡඼ಠಛͷ࡞๏Λशಘ͠ͳ͚Ε͹͍͚ͳ͍ͷͰɺڭҭίετ
    ͕ലେʢ࣌ؒͱඅ༻ڞʹʣ
    άάϨ͹ࡁΉͱ͔͍͏؆୯ͳ࿩Ͱ͸ͳ͍ɻ
    Démonstration.
    ໰୊఺ͷղফ
    ϦΞϧۀ຿ΞϓϦʹରͯ͠ิॿతͳ֎෇͚γεςϜΛ։ൃ
    ϦΞϧۀ຿ΞϓϦͰ͸खͷራ͘ʹ͍͘খճΓͳ࡞ۀΛΧόʔ͢Δγ
    εςϜ
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 39 / 41

    View full-size slide









































  40. ϦΞϧۀ຿ΞϓϦέʔγϣϯಋೖޙͷ՝୊̎
    Example
    ಋೖޙͷ໰୊఺
    ػೳ͕੝Γ୔ࢁͳ͍͔ͤɺ಺෦ॲཧ͕ଟׂ͍͍͔ͤͱΞϓϦʔέʔ
    γϣϯͷεϐʔυͱͯ͠͸ᬌ͍ɻಛʹݕࡧ΍রձͳͲ
    σʔλྔ͕ଟ͘ͳͬͯ͘ΔͱݦஶʹϘτϧωοΫ͕ग़࢝ΊΔ
    Démonstration.
    ໰୊఺ͷղফ
    ओۀ຿ΞϓϦέʔγϣϯͰ஝͍͑ͯΔ DB Λ௚઀ΩοΫ͢Δ֎෇γ
    εςϜΛ։ൃ
    ৔߹ʹΑͬͯ͸ɺ֎෇γεςϜͰϦΞϧۀ຿ΞϓϦέʔγϣϯͷػ
    ೳΛҰ෦୅ߦ͢Δ

    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 40 / 41

    View full-size slide









































  41. ຊηογϣϯͷ Laravel ۀ຿ΞϓϦͷ૬Ԡ͍͠Ґஔ෇
    ϦΞϧۀ຿ΞϓϦͷػೳΛҰ෦୅ߦ͢ΔγεςϜΛ Laravel Ͱ࡞ͬͯ
    Έ·ͤΜ͔ʁ
    ϦΞϧۀ຿ΞϓϦΛۦஞ͢Δૂ͍Ͱ͸ͳ͍ɻͳͥͳΒɺPHP ͷݴޠࣗ
    ମ͕ീํඒਓͰ͸ͳ͍ɻJava ͸ീํඒਓɻͳͥͳΒɺ΢Σϒ͚ͩʹ߆
    Δඞཁ͕ͳ͍͔Βɻ
    ͓ݎ͍ۀ຿ΞϓϦͱ͍͑͹ɺJava ͷէ৓
    ࣮੷ͱ͍͏໊ͷΠϝʔδઌߦɻ
    (PHP ͰΫϥεͷͳ͔ͬͨ࣌୅ͳΒ Java ʹউ໨͸ͳ͍ͩΖ͏͕ɾ
    ɾ
    ɾ)
    Java Ͱ࡞ΒΕͨమ൘খن໛ΞϓϦͳΒ
    Laravel ͰαΫͬͱΫϩʔϯ࡞੒Մೳ
    Java ͷϏδωεͷէ৓ͷҰ෦Λ੾Γ่ͤΔഁյೳྗे෼༗
    ࡔຊ߶඙ @sakamoto03 (Sodick Co., Ltd.) ͙͢෼͔ΔʂLaravel PHP ΧϯϑΝϨϯεؔ੢ 41 / 41

    View full-size slide