l4 Offline Doc

download l4 Offline Doc

of 310

Transcript of l4 Offline Doc

  • 8/12/2019 l4 Offline Doc

    1/310

  • 8/12/2019 l4 Offline Doc

    2/310

    Laravel 4 Docs (Updated for 4.1.x)

    Up-to-date Offline Documentation

    M N Islam Shihan

    This book is for sale athttp://leanpub.com/l4-offline-doc

    This version was published on 2014-01-30

    This is aLeanpubbook. Leanpub empowers authors and publishers with the Lean Publishing

    process.Lean Publishingis the act of publishing an in-progress ebook using lightweight tools andmany iterations to get reader feedback, pivot until you have the right book and build traction onceyou do.

    This work is licensed under aCreative Commons Attribution-NonCommercial-ShareAlike 3.0Unported License

    http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_UShttp://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_UShttp://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_UShttp://leanpub.com/manifestohttp://leanpub.com/http://leanpub.com/l4-offline-doc
  • 8/12/2019 l4 Offline Doc

    3/310

    Tweet This Book!

    Please help M N Islam Shihan by spreading the word about this book on Twitter!

    The suggested tweet for this book is:

    @laravelphp I just bought offline version of Laravel Docs from @leanpub which is completely free& in sync with latest official docs

    The suggested hashtag for this book is#laravel.

    Find out what other people are saying about the book by clicking on this link to search for thishashtag on Twitter:

    https://twitter.com/search?q=#laravel

    https://twitter.com/search?q=%23laravelhttps://twitter.com/search?q=%23laravelhttp://twitter.com/
  • 8/12/2019 l4 Offline Doc

    4/310

    Taylor Otwell along with entire Laravel community

  • 8/12/2019 l4 Offline Doc

    5/310

    Contents

    Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Where To Start . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Laravel Philosophy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1Additional Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2Development Team . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Laravel Quickstart. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Creating A View . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Creating A Migration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6Eloquent ORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7Displaying Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    Release Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9Laravel 4.1 {#releases-laravel-4.1} . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    Upgrade Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12Upgrading To 4.2 From 4.1 {#upgrade-upgrade-4.2} . . . . . . . . . . . . . . . . . . . . . . 12Upgrading To 4.1 From 4.0 {#upgrade-upgrade-4.1} . . . . . . . . . . . . . . . . . . . . . . 12

    Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Install Composer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Install Laravel . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15Server Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16Pretty URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18Environment Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19Maintenance Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    Request Lifecycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

  • 8/12/2019 l4 Offline Doc

    6/310

    CONTENTS

    Request Lifecycle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23Start Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24Application Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Basic Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26Route Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28Route Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30Named Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33Route Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34Sub-Domain Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Route Prefixing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35Route Model Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36Throwing 404 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37Routing To Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    Requests & Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Basic Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39Cookies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40Old Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42Request Information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    Views & Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Basic Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48Redirects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51View Composers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53Special Responses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55Response Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Basic Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57Controller Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59RESTful Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61Resource Controllers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62Handling Missing Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    Errors & Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Error Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65Handling Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65HTTP Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Handling 404 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

  • 8/12/2019 l4 Offline Doc

    7/310

    CONTENTS

    Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Storing Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69Authenticating Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    Manually Logging In Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73Protecting Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73HTTP Basic Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74Password Reminders & Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

    Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Cache Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80Increments & Decrements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83Cache Tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

    Database Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    Extending The Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Managers & Factories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86Where To Extend . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87Cache . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91IoC Based Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92Request Extension . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    Events. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96Wildcard Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97Using Classes As Listeners . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98Queued Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99Event Subscribers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102Explanation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

    Practical Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103Creating Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104Mocking Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105Facade Class Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    Forms & HTML . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108Opening A Form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

  • 8/12/2019 l4 Offline Doc

    8/310

    CONTENTS

    CSRF Protection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109Form Model Binding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110Labels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111Text, Text Area, Password & Hidden Fields . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    Checkboxes and Radio Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112File Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112Drop-Down Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113Buttons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114Custom Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114Generating URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    Helper Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116Paths . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122

    URLs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126Miscellaneous . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 128

    IoC Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130Where To Register Bindings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131Automatic Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132Practical Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133Service Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134Container Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

    Localization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Language Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138Pluralization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140Overriding Package Language Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

    Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141Embedding Inline Attachments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143Queueing Mail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143Mail & Local Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

    Package Development. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

  • 8/12/2019 l4 Offline Doc

    9/310

    CONTENTS

    Creating A Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Package Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147Service Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148Package Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

    Development Workflow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Package Routing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150Package Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151Package Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152Package Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153Package Assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154Publishing Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    Pagination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

    Appending To Pagination Links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158Converting To JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

    Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160Queueing Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164Running The Queue Listener . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165Push Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166Failed Jobs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

    Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Storing Passwords . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170Authenticating Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171Manually Logging In Users . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174Protecting Routes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174HTTP Basic Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175Password Reminders & Reset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177Encryption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    Session . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181Session Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181Flash Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183Database Sessions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184Session Drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

    SSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186

  • 8/12/2019 l4 Offline Doc

    10/310

    CONTENTS

    Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186Tasks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187SFTP Uploads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    Tailing Remote Logs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188

    Templates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Controller Layouts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Blade Templating . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189Other Blade Control Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    Unit Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Defining & Running Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195Test Environment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    Calling Routes From Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196Mocking Facades . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198Framework Assertions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199Helper Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201Refreshing The Application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

    Validation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202Working With Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204Error Messages & Views . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206Available Validation Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

    Conditionally Adding Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213Custom Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214Custom Validation Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216

    Basic Database Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Read / Write Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218Running Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219Database Transactions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220Accessing Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221Query Logging . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222

    Query Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Selects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224Joins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228Advanced Wheres . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229Aggregates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231

  • 8/12/2019 l4 Offline Doc

    11/310

    CONTENTS

    Raw Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 231Inserts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232Updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233Deletes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233

    Unions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234Pessimistic Locking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 234Caching Queries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

    Eloquent ORM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Basic Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 236Mass Assignment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 240Insert, Update, Delete . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241Soft Deleting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246

    Query Scopes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247Relationships . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249Querying Relations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257Eager Loading . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 259Inserting Related Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262Touching Parent Timestamps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 264Working With Pivot Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265Collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267Accessors & Mutators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269Date Mutators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270

    Model Events . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271Model Observers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272Converting To Arrays / JSON . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273

    Schema Builder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276Creating & Dropping Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 276Adding Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277Renaming Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278Dropping Columns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279Checking Existence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279

    Adding Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280Foreign Keys . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Dropping Indexes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281Storage Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

    Migrations & Seeding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

  • 8/12/2019 l4 Offline Doc

    12/310

    CONTENTS

    Creating Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283Running Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284Rolling Back Migrations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284Database Seeding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

    Redis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289Pipelining . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290

    Artisan CLI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291

    Artisan Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Building A Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 293Registering Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 297Calling Other Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298

  • 8/12/2019 l4 Offline Doc

    13/310

    Introduction

    Where To Start

    Laravel Philosophy

    Additional Resources

    Development Team

    Where To Start

    Learning a new framework can be daunting, but its also exciting. To smooth your transition, weve

    attempted to create very clear, concise documentation for Laravel. Here are some recommendationsfor what to read first:

    InstallationandConfiguration

    Routing

    Requests & Input

    Views & Responses

    Controllers

    After reading through these documents, you should have a good grasp on basic request / responsehandling in Laravel. Next, you may wish to read aboutconfiguring your database, thefluent querybuilder, and theEloquent ORM. Or, you may wish to read aboutauthentication and securityso youcan start signing people into your application.

    Laravel Philosophy

    Laravel is a web application framework with expressive, elegant syntax. We believe developmentmust be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain outof development by easing common tasks used in the majority of web projects, such as authentication,routing, sessions, and caching.

    Laravel aims to make the development process a pleasing one for the developer without sacrificingapplication functionality. Happy developers make the best code. To this end, weve attempted tocombine the very best of what we have seen in other web frameworks, including frameworksimplemented in other languages, such as Ruby on Rails, ASP.NET MVC, and Sinatra.

    Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications.A superb inversion of control container, expressive migration system, and tightly integrated unittesting support give you the tools you need to build any application with which you are tasked.

  • 8/12/2019 l4 Offline Doc

    14/310

    Introduction 2

    Additional Resources

    One of the best ways to learn Laravel is to read through the entirety of its documentation. This guide

    details all aspects of the framework and how to apply them to your application.In addition to this guide, you may wish to check out someLaravel books. These community writtenbooks serve as a good supplemental resource for learning about the framework:

    Code Brightby Dayle Rees

    Laravel Testing Decodedby Jeffrey Way

    Laravel: From Apprentice To Artisanby Taylor Otwell

    Implementing Laravelby Chris Fidao

    Getting Stuff Done With Laravel 4by Chuck Heintzelman

    Laravel 4 Cookbookby Christopher Pitt

    Laravel in Actionby Maks Surguy

    Development Team

    Laravel was created byTaylor Otwell, who continues to lead development of the framework. Otherprominent community members and contributors includeDayle Rees,Shawn McCool,JeffreyWay,Jason Lewis,Ben Corlett,Franz Liedke,Dries Vints,Mior Muhammad Zaki, andPhilSturgeon.

    http://wiki.laravel.io/Books

    https://leanpub.com/codebrighthttps://leanpub.com/laravel-testing-decodedhttps://leanpub.com/laravelhttps://leanpub.com/implementinglaravelhttps://leanpub.com/gettingstuffdonelaravelhttps://leanpub.com/laravel4cookbookhttp://www.manning.com/surguy/https://github.com/taylorotwell

    https://github.com/daylereeshttps://github.com/ShawnMcCoolhttps://github.com/JeffreyWayhttps://github.com/jasonlewishttps://github.com/bencorlett

    https://github.com/franzliedke

    https://github.com/driesvintshttps://github.com/crynobonehttps://github.com/philsturgeon

    https://github.com/philsturgeonhttps://github.com/crynobonehttps://github.com/driesvintshttps://github.com/franzliedkehttps://github.com/bencorletthttps://github.com/jasonlewishttps://github.com/JeffreyWayhttps://github.com/ShawnMcCoolhttps://github.com/daylereeshttps://github.com/taylorotwellhttp://www.manning.com/surguy/https://leanpub.com/laravel4cookbookhttps://leanpub.com/gettingstuffdonelaravelhttps://leanpub.com/implementinglaravelhttps://leanpub.com/laravelhttps://leanpub.com/laravel-testing-decodedhttps://leanpub.com/codebrighthttp://wiki.laravel.io/Bookshttps://github.com/philsturgeonhttps://github.com/philsturgeonhttps://github.com/crynobonehttps://github.com/driesvintshttps://github.com/franzliedkehttps://github.com/bencorletthttps://github.com/jasonlewishttps://github.com/JeffreyWayhttps://github.com/JeffreyWayhttps://github.com/ShawnMcCoolhttps://github.com/daylereeshttps://github.com/taylorotwellhttp://www.manning.com/surguy/https://leanpub.com/laravel4cookbookhttps://leanpub.com/gettingstuffdonelaravelhttps://leanpub.com/implementinglaravelhttps://leanpub.com/laravelhttps://leanpub.com/laravel-testing-decodedhttps://leanpub.com/codebrighthttp://wiki.laravel.io/Books
  • 8/12/2019 l4 Offline Doc

    15/310

    Laravel Quickstart Installation

    Routing

    Creating A View

    Creating A Migration

    Eloquent ORM

    Displaying Data

    InstallationThe Laravel framework utilizes Composerfor installation and dependency management. If youhavent already, start byinstalling Composer.

    Now you can install Laravel by issuing the following command from your terminal:

    composer create-project laravel/laravel your-project-name --prefer-dist

    This command will download and install a fresh copy of Laravel in a newyour-project-namefolderwithin your current directory.

    If you prefer, you can alternatively download a copy of the Laravel repository from Githubmanually. Next run the composer installcommand in the root of your manually created projectdirectory. This command will download and install the frameworks dependencies.

    Permissions

    After installing Laravel, you may need to grant the web server write permissions to theapp/storage

    directories. See theInstallationdocumentation for more details on configuration.

    http://getcomposer.orghttp://getcomposer.org/doc/00-intro.mdhttps://github.com/laravel/laravel/archive/master.zip

    https://github.com/laravel/laravel/archive/master.ziphttp://getcomposer.org/doc/00-intro.mdhttp://getcomposer.org/https://github.com/laravel/laravel/archive/master.ziphttp://getcomposer.org/doc/00-intro.mdhttp://getcomposer.org/
  • 8/12/2019 l4 Offline Doc

    16/310

    Laravel Quickstart 4

    Directory Structure

    After installing the framework, take a glance around the project to familiarize yourself with thedirectory structure. Theapp directory contains folders such asviews, controllers,and models. Most

    of your applications code will reside somewhere in this directory. You may also wish to explore theapp/configdirectory and the configuration options that are available to you.

    Routing

    To get started, lets create our first route. In Laravel, the simplest route is a route to a Closure. Popopen theapp/routes.phpfile and add the following route to the bottom of the file:

    Route::get('users', function(){

    return 'Users!';

    });

    Now, if you hit the /users route in your web browser, you should see Users! displayed as theresponse. Great! Youve just created your first route.

    Routes can also be attached to controller classes. For example:

    Route::get('users', 'UserController@getIndex');

    This route informs the framework that requests to the /usersroute should call thegetIndexmethodon the UserControllerclass. For more information on controller routing, check out the controllerdocumentation.

    Creating A View

    Next, well create a simple view to display our user data. Views live in the app/views directoryand contain the HTML of your application. Were going to place two new views in this directory:layout.blade.phpand users.blade.php. First, lets create our layout.blade.phpfile:

  • 8/12/2019 l4 Offline Doc

    17/310

    Laravel Quickstart 5

    Laravel Quickstart

    @yield('content')

    Next, well create our users.blade.phpview:

    @extends('layout')

    @section('content')

    Users!

    @stop

    Some of this syntax probably looks quite strange to you. Thats because were using Laravelstemplating system: Blade. Blade is very fast, because it is simply a handful of regular expressions thatare run against your templates to compile them to pure PHP. Blade provides powerful functionality

    like template inheritance, as well as some syntax sugar on typical PHP control structures such as ifandfor. Check out theBlade documentationfor more details.

    Now that we have our views, lets return it from our /usersroute. Instead of returning Users!fromthe route, return the view instead:

    Route::get('users', function()

    {

    return View::make('users');

    });

    Wonderful! Now you have setup a simple view that extends a layout. Next, lets start working onour database layer.

  • 8/12/2019 l4 Offline Doc

    18/310

    Laravel Quickstart 6

    Creating A Migration

    To create a table to hold our data, well use the Laravel migration system. Migrations let you

    expressively define modifications to your database, and easily share them with the rest of yourteam.

    First, lets configure a database connection. You may configure all of your database connections fromthe app/config/database.phpfile. By default, Laravel is configured to use MySQL, and you willneed to supply connection credentials within the database configuration file. If you wish, you maychange thedriver option tosqlite and it will use the SQLite database included in theapp/databasedirectory.

    Next, to create the migration, well use the Artisan CLI. From the root of your project, run thefollowing from your terminal:

    php artisan migrate:make create_users_table

    Next, find the generated migration file in the app/database/migrationsfolder. This file containsa class with two methods: up and down. In the up method, you should make the desired changes toyour database tables, and in the downmethod you simply reverse them.

    Lets define a migration that looks like this:

    public function up()

    {

    Schema::create('users', function($table)

    {

    $table->increments('id');

    $table->string('email')->unique();

    $table->string('name');

    $table->timestamps();

    });

    }

    public function down()

    {

    Schema::drop('users');

    }

  • 8/12/2019 l4 Offline Doc

    19/310

    Laravel Quickstart 7

    Next, we can run our migrations from our terminal using the migratecommand. Simply executethis command from the root of your project:

    php artisan migrate

    If you wish to rollback a migration, you may issue the migrate:rollbackcommand. Now that wehave a database table, lets start pulling some data!

    Eloquent ORM

    Laravel ships with a superb ORM: Eloquent. If you have used the Ruby on Rails framework, youwill find Eloquent familiar, as it follows the ActiveRecord ORM style of database interaction.

    First, lets define a model. An Eloquent model can be used to query an associated database table, aswell as represent a given row within that table. Dont worry, it will all make sense soon! Models aretypically stored in the app/modelsdirectory. Lets define a User.phpmodel in that directory like so:

    class User extends Eloquent {}

    Note that we do not have to tell Eloquent which table to use. Eloquent has a variety of conventions,one of which is to use the plural form of the model name as the models database table. Convenient!

    Using your preferred database administration tool, insert a few rows into your userstable, and welluse Eloquent to retrieve them and pass them to our view.

    Now lets modify our/usersroute to look like this:

    Route::get('users', function()

    {

    $users = User::all();

    return View::make('users')->with('users', $users);

    });

  • 8/12/2019 l4 Offline Doc

    20/310

    Laravel Quickstart 8

    Lets walk through this route. First, the all method on the Usermodel will retrieve all of the rowsin the users table. Next, were passing these records to the view via the withmethod. The withmethod accepts a key and a value, and is used to make a piece of data available to a view.

    Awesome. Now were ready to display the users in our view!

    Displaying Data

    Now that we have made theusersavailable to our view. We can display them like so:

    @extends('layout')

    @section('content')

    @foreach($users as $user)

    {{ $user->name }}

    @endforeach

    @stop

    You may be wondering where to find our echostatements. When using Blade, you may echo databy surrounding it with double curly braces. Its a cinch. Now, you should be able to hit the /usersroute and see the names of your users displayed in the response.

    This is just the beginning. In this tutorial, youve seen the very basics of Laravel, but there are somany more exciting things to learn. Keep reading through the documentation and dig deeper intothe powerful features available to you inEloquentandBlade. Or, maybe youre more interested inQueuesandUnit Testing. Then again, maybe you want to flex your architecture muscles with theIoC Container. The choice is yours!

  • 8/12/2019 l4 Offline Doc

    21/310

    Release Notes Laravel 4.1

    Laravel 4.1 {#releases-laravel-4.1}

    Full Change List

    The full change list for this release by running the php artisan changes command from a4.1 installation, or by viewing the change file on Github. These notes only cover the majorenhancements and changes for the release.

    New SSH Component

    An entirely new SSH component has been introduced with this release. This feature allows youto easily SSH into remote servers and run commands. To learn more, consult theSSH componentdocumentation.

    The new php artisan tailcommand utilizes the new SSH component. For more information,consult the tailcommand documentation.

    Boris In Tinker

    The php artisan tinkercommand now utilizes theBoris REPLif your system supports it. Thereadlineand pcntlPHP extensions must be installed to use this feature. If you do not have theseextensions, the shell from 4.0 will be used.

    Eloquent Improvements

    A newhasManyThroughrelationship has been added to Eloquent. To learn how to use it, consult the

    Eloquent documentation.

    A newwhereHasmethod has also been introduced to allowretrieving models based on relationshipconstraints.

    https://github.com/laravel/framework/blob/4.1/src/Illuminate/Foundation/changes.jsonhttp://laravel.com/docs/ssh#tailing-remote-logshttps://github.com/d11wtq/boris

    https://github.com/d11wtq/borishttp://laravel.com/docs/ssh#tailing-remote-logshttps://github.com/laravel/framework/blob/4.1/src/Illuminate/Foundation/changes.jsonhttps://github.com/d11wtq/borishttp://laravel.com/docs/ssh#tailing-remote-logshttps://github.com/laravel/framework/blob/4.1/src/Illuminate/Foundation/changes.jsonhttp://-/?-
  • 8/12/2019 l4 Offline Doc

    22/310

    Release Notes 10

    Database Read / Write Connections

    Automatic handling of separate read / write connections is now available throughout the databaselayer, including the query builder and Eloquent. For more information, consultthe documentation.

    Queue Priority

    Queue priorities are now supported by passing a comma-delimited list to the queue:listencommand.

    Failed Queue Job Handling

    The queue facilities now include automatic handling of failed jobs when using the new --triesswitch on queue:listen. More information on handling failed jobs can be found in the queue

    documentation.

    Cache Tags

    Cache sections have been superseded by tags. Cache tags allow you to assign multiple tags toa cache item, and flush all items assigned to a single tag. More information on using cache tags maybe found in thecache documentation.

    Flexible Password Reminders

    The password reminder engine has been changed to provide greater developer flexibility whenvalidating passwords, flashing status messages to the session, etc. For more information on usingthe enhanced password reminder engine,consult the documentation.

    Improved Routing Engine

    Laravel 4.1 features a totally re-written routing layer. The API is the same; however, registeringroutes is a full 100% faster compared to 4.0. The entire engine has been greatly simplified, and thedependency on Symfony Routing has been minimized to the compiling of route expressions.

    Improved Session Engine

    With this release, were also introducing an entirely new session engine. Similar to the routingimprovements, the new session layer is leaner and faster. We are no longer using Symfonys (andtherefore PHPs) session handling facilites, and are using a custom solution that is simpler and easierto maintain.

  • 8/12/2019 l4 Offline Doc

    23/310

    Release Notes 11

    Doctrine DBAL

    If you are using the renameColumn function in your migrations, you will need to add thedoctrine/dbaldependency to your composer.jsonfile. This package is no longer included in Laravel by default.

  • 8/12/2019 l4 Offline Doc

    24/310

    Upgrade Guide Upgrading To 4.2 From 4.1

    Upgrading To 4.1 From 4.0

    Upgrading To 4.2 From 4.1 {#upgrade-upgrade-4.2}

    PHP 5.4+

    Laravel 4.2 requires PHP 5.4.0 or greater.

    View / Pagination Environment Renamed

    If you are directly referencing the Illuminate\View\Environment class or Illuminate\Pagination\Environclass, update your code to reference Illuminate\View\Factory and Illuminate\Pagination\Factoryinstead. These two classes have been renamed to better reflect their function.

    Upgrading To 4.1 From 4.0 {#upgrade-upgrade-4.1}

    Upgrading Your Composer Dependency

    To upgrade your application to Laravel 4.1, change your laravel/framework version to 4.1.* inyour composer.jsonfile.

    Replacing Files

    Replace yourpublic/index.phpfile withthis fresh copy from the repository.

    Replace yourartisanfile withthis fresh copy from the repository.

    https://github.com/laravel/laravel/blob/master/public/index.phphttps://github.com/laravel/laravel/blob/master/artisan

    https://github.com/laravel/laravel/blob/master/artisanhttps://github.com/laravel/laravel/blob/master/public/index.phphttps://github.com/laravel/laravel/blob/master/artisanhttps://github.com/laravel/laravel/blob/master/public/index.phphttp://-/?-http://-/?-
  • 8/12/2019 l4 Offline Doc

    25/310

    Upgrade Guide 13

    Adding Configuration Files & Options

    Update your aliases and providers arrays in your app/config/app.php configuration file. Theupdated values for these arrays can be foundin this file. Be sure to add your custom and package

    service providers / aliases back to the arrays.

    Add the newapp/config/remote.phpfilefrom the repository.

    Add the new expire_on_close configuration option to your app/config/session.php file. Thedefault value should be false.

    Add the new failedconfiguration section to your app/config/queue.phpfile. Here are the defaultvalues for the section:

    'failed' => array(

    'database' => 'mysql', 'table' => 'failed_jobs',

    ),

    (Optional) Update the pagination configuration option in your app/config/view.php file topagination::slider-3.

    Controller Updates

    Ifapp/controllers/BaseController.php hasa use statement at the top, change use Illuminate\Routing\

    touse Illuminate\Routing\Controller;.

    Password Reminders Updates

    Password reminders have been overhauled for greater flexibility. You may examine the new stubcontroller by running the php artisan auth:reminders-controllerArtisan command. You mayalso browse theupdated documentationand update your application accordingly.

    Update yourapp/lang/en/reminders.phplanguage file to matchthis updated file.

    Environment Detection Updates

    For security reasons, URL domains may no longer be used to detect your application environment.These values are easily spoofable and allow attackers to modify the environment for a request. Youshould convert your environment detection to use machine host names (hostnamecommand on Mac& Ubuntu).

    https://github.com/laravel/laravel/blob/master/app/config/app.phphttps://github.com/laravel/laravel/blob/master/app/config/remote.phphttps://github.com/laravel/laravel/blob/master/app/lang/en/reminders.php

    https://github.com/laravel/laravel/blob/master/app/lang/en/reminders.phphttps://github.com/laravel/laravel/blob/master/app/config/remote.phphttps://github.com/laravel/laravel/blob/master/app/config/app.phphttps://github.com/laravel/laravel/blob/master/app/lang/en/reminders.phphttps://github.com/laravel/laravel/blob/master/app/config/remote.phphttps://github.com/laravel/laravel/blob/master/app/config/app.php
  • 8/12/2019 l4 Offline Doc

    26/310

    Upgrade Guide 14

    Simpler Log Files

    Laravel now generates a single log file: app/storage/logs/laravel.log. However, you may stillconfigure this behavior in your app/start/global.phpfile.

    Removing Redirect Trailing Slash

    In your bootstrap/start.php file, remove the call to $app->redirectIfTrailingSlash(). Thismethod is no longer needed as this functionality is now handled by the .htaccess file includedwith the framework.

    Next, replace your Apache.htaccessfile withthis new onethat handles trailing slashes.

    Current Route Access

    The current route is now accessed via Route::current()instead ofRoute::getCurrentRoute().

    Composer Update

    Once you have completed the changes above, you can run the composer updatefunction to updateyour core application files! If you receive class load errors, try running the updatecommand withthe--no-scriptsoption enabled like so: composer update --no-scripts.

    https://github.com/laravel/laravel/blob/master/public/.htaccess

    https://github.com/laravel/laravel/blob/master/public/.htaccesshttps://github.com/laravel/laravel/blob/master/public/.htaccess
  • 8/12/2019 l4 Offline Doc

    27/310

    Installation Install Composer

    Install Laravel

    Server Requirements

    Configuration

    Pretty URLs

    Install Composer

    Laravel utilizes Composer to manage its dependencies. First, download a copy of the composer.phar.Once you have the PHAR archive, you can either keep it in your local project directory or move tousr/local/binto use it globally on your system. On Windows, you can use the ComposerWindowsinstaller.

    Install Laravel

    Via Laravel Installer

    First, download theLaravel installer PHAR archive. For convenience, rename the file to laraveland move it to /usr/local/bin. Once installed, the simple laravel newcommand will create afresh Laravel installation in the directory you specify. For instance,laravel new blogwould createa directory namedblogcontaining a fresh Laravel installation with all dependencies installed. Thismethod of installation is much faster than installing via Composer.

    Via Composer Create-Project

    You may also install Laravel by issuing the Composer create-projectcommand in your terminal:

    composer create-project laravel/laravel --prefer-dist

    http://getcomposer.orghttps://getcomposer.org/Composer-Setup.exehttp://laravel.com/laravel.phar

    http://laravel.com/laravel.pharhttps://getcomposer.org/Composer-Setup.exehttp://getcomposer.org/http://laravel.com/laravel.pharhttps://getcomposer.org/Composer-Setup.exehttps://getcomposer.org/Composer-Setup.exehttp://getcomposer.org/
  • 8/12/2019 l4 Offline Doc

    28/310

    Installation 16

    Via Download

    Once Composer is installed, download the latest versionof the Laravel framework and extractits contents into a directory on your server. Next, in the root of your Laravel application, run the

    php composer.phar install (or composer install) command to install all of the frameworksdependencies. This process requires Git to be installed on the server to successfully complete theinstallation.

    If you want to update the Laravel framework, you may issue the php composer.phar updatecommand.

    Server Requirements

    The Laravel framework has a few system requirements:

    PHP >= 5.3.7

    MCrypt PHP Extension

    As of PHP 5.5, some OS distributions may require you to manually install the PHP JSON extension.When using Ubuntu, this can be done via apt-get install php5-json.

    Configuration

    Laravel needs almost no configuration out of the box. You are free to get started developing!However, you may wish to review the app/config/app.phpfile and its documentation. It containsseveral options such as timezone and locale that you may wish to change according to yourapplication.

    Permissions

    Laravel may require one set of permissions to be configured: folders within app/storage require writeaccess by the web server.

    Paths

    Several of the framework directory paths are configurable. To change the location of thesedirectories, check out the bootstrap/paths.phpfile.

    https://github.com/laravel/laravel/archive/master.zip

    https://github.com/laravel/laravel/archive/master.ziphttps://github.com/laravel/laravel/archive/master.zip
  • 8/12/2019 l4 Offline Doc

    29/310

    Installation 17

    Pretty URLs

    The framework ships with a public/.htaccessfile that is used to allow URLs without index.php.

    If you use Apache to serve your Laravel application, be sure to enable the mod_rewritemodule.If the .htaccessfile that ships with Laravel does not work with your Apache installation, try thisone:

    Options +FollowSymLinks

    RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} !-d

    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteRule ^ index.php [L]

  • 8/12/2019 l4 Offline Doc

    30/310

    Configuration Introduction

    Environment Configuration

    Maintenance Mode

    Introduction

    All of the configuration files for the Laravel framework are stored in the app/configdirectory. Each

    option in every file is documented, so feel free to look through the files and get familiar with theoptions available to you.

    Sometimes you may need to access configuration values at run-time. You may do so using theConfigclass:

    Accessing A Configuration Value

    Config::get('app.timezone');

    You may also specify a default value to return if the configuration option does not exist:

    $timezone = Config::get('app.timezone', 'UTC');

    Notice that dot style syntax may be used to access values in the various files. You may also set

    configuration values at run-time:

    Setting A Configuration Value

  • 8/12/2019 l4 Offline Doc

    31/310

    Configuration 19

    Config::set('database.default', 'sqlite');

    Configuration values that are set at run-time are only set for the current request, and will not becarried over to subsequent requests.

    Environment Configuration

    It is often helpful to have different configuration values based on the environment the applicationis running in. For example, you may wish to use a different cache driver on your local developmentmachine than on the production server. It is easy to accomplish this using environment based

    configuration.Simply create a folder within the configdirectory that matches your environment name, such aslocal. Next, create the configuration files you wish to override and specify the options for thatenvironment. For example, to override the cache driver for the local environment, you would createa cache.phpfile in app/config/localwith the following content:

  • 8/12/2019 l4 Offline Doc

    32/310

    Configuration 20

  • 8/12/2019 l4 Offline Doc

    33/310

    Configuration 21

    if (App::environment('local'))

    {

    // The environment is local}

    if (App::environment('local', 'staging'))

    {

    // The environment is either local OR staging...

    }

    Maintenance Mode

    When your application is in maintenance mode, a custom view will be displayed for all routesinto your application. This makes it easy to disable your application while it is updating orwhen you are performing maintenance. A call to the App::down method is already present inyour app/start/global.phpfile. The response from this method will be sent to users when yourapplication is in maintenance mode.

    To enable maintenance mode, simply execute the downArtisan command:

    php artisan down

    To disable maintenance mode, use the upcommand:

    php artisan up

    To show a custom view when your application is in maintenance mode, you may add somethinglike the following to your applications app/start/global.phpfile:

  • 8/12/2019 l4 Offline Doc

    34/310

    Configuration 22

    App::down(function()

    {

    return Response::view('maintenance', array(), 503);

    });

    If the Closure passed to the downmethod returns NULL, maintenace mode will be ignored for thatrequest.

    Maintenance Mode & Queues

    While your application is in maintenance mode, no queue jobs will be handled. The jobs will

    continue to be handled as normal once the application is out of maintenance mode.

  • 8/12/2019 l4 Offline Doc

    35/310

    Request Lifecycle Overview

    Request Lifecycle

    Start Files

    Application Events

    Overview

    When using any tool in the real world, you feel more confidence if you understand how that tool

    works. Application development is no different. When you understand how your development toolsfunction, you feel more comfortable and confident using them. The goal of this document is to giveyou a good, high-level overview of how the Laravel framework works. By getting to know theoverall framework better, everything feels less magical and you will be more confident buildingyour applications. In addition to a high-level overview of the request lifecycle, well cover startfiles and application events.

    If you dont understand all of the terms right away, dont lose heart! Just try to get a basic grasp ofwhat is going on, and your knowledge will grow as you explore other sections of the documentation.

    Request LifecycleAll requests into your application are directed through the public/index.phpscript. When usingApache, the.htaccessfile that ships with Laravel handles the passing of all requests to index.php.From here, Laravel begins the process of handling the requests and returning a response to the client.Getting a general idea for the Laravel bootstrap process will be useful, so well cover that now!

    By far, the most important concept to grasp when learning about Laravels bootstrap process isService Providers. You can find a list of service providers by opening your app/config/app.phpconfiguration file and finding the providersarray. These providers serve as the primary bootstrap-ping mechanism for Laravel. But, before we dig into service providers, lets go back to index.php.

    After a request enters your index.phpfile, the bootstrap/start.phpfile will be loaded. This filecreates the new Laravel Applicationobject, which also serves as anIoC container.

    After creating theApplication object, a few project paths will be set andenvironment detectionwillbe performed. Then, an internal Laravel bootstrap script will be called. This file lives deep withinthe Laravel source, and sets a few more settings based on your configuration files, such as timezone,error reporting, etc. But, in addition to setting these rather trivial configuration options, it also doessomething very important: registers all of the service providers configured for your application.

  • 8/12/2019 l4 Offline Doc

    36/310

    Request Lifecycle 24

    Simple service providers only have one method: register. This registermethod is called whenthe service provider is registered with the application object via the applications own registermethod. Within this method, service providers register things with theIoC container. Essentially,each service provider binds one or moreclosuresinto the container, which allows you to access

    those bound services within your application. So, for example, the QueueServiceProviderregistersclosures that resolve the variousQueuerelated classes. Of course, service providers may be used forany bootstrapping task, not just registering things with the IoC container. A service provider mayregister event listeners, view composers, Artisan commands, and more.

    After all of the service providers have been registered, your app/startfiles will be loaded. Lastly,your app/routes.phpfile will be loaded. Once your routes.phpfile has been loaded, the Requestobject is sent to the application so that it may be dispatched to a route.

    So, lets summarize:

    1. Request enterspublic/index.phpfile.

    2. bootstrap/start.phpfile creates Application and detects environment.3. Internalframework/start.phpfile configures settings and loads service providers.

    4. Applicationapp/startfiles are loaded.

    5. Applicationapp/routes.phpfile is loaded.

    6. Request object sent to Application, which returns Response object.

    7. Response object sent back to client.

    Now that you have a good idea of how a request to a Laravel application is handled, lets take acloser look at start files!

    Start FilesYour applications start files are stored at app/start. By default, three are included with yourapplication: global.php, local.php, and artisan.php. For more information about artisan.php,refer to the documentation on theArtisan command line.

    Theglobal.phpstart file contains a few basic items by default, such as the registration of theLoggerand the inclusion of your app/filters.phpfile. However, you are free to add anything to this filethat you wish. It will be automatically included oneveryrequest to your application, regardless ofenvironment. Thelocal.phpfile, on the other hand, is only called when the application is executingin the local environment. For more information on environments, check out the configurationdocumentation.

    Of course, if you have other environments in addition to local, you may create start files forthose environments as well. They will be automatically included when your application is runningin that environment. So, for example, if you have a development environment configured inyour bootstrap/start.phpfile, you may create a app/start/development.phpfile, which will beincluded when any requests enter the application in that environment.

    http://us3.php.net/manual/en/functions.anonymous.php

    http://us3.php.net/manual/en/functions.anonymous.phphttp://us3.php.net/manual/en/functions.anonymous.php
  • 8/12/2019 l4 Offline Doc

    37/310

    Request Lifecycle 25

    What To Place In Start Files

    Start files serve as a simple place to place any bootstrapping code. For example, you could registera View composer, configure your logging preferences, set some PHP settings, etc. Its totally up to

    you. Of course, throwing all of your bootstrapping code into your start files can get messy. For largeapplications, or if you feel your start files are getting messy, consider moving some bootstrappingcode intoservice providers.

    Application Events

    You may also do pre and post request processing by registering before,after,finish, andshutdownapplication events:

    Registering Application Events

    App::before(function($request)

    {

    //

    });

    App::after(function($request, $response)

    {

    //

    });

    Listeners to these events will be run beforeandaftereach request to your application. These eventscan be helpful for global filtering or global modification of responses. You may register them in oneof yourstartfiles or in aservice provider.

    Thefinishevent is called after the response from your application has been sent back to the client.This is a good place to do any last minute processing your application requires. Theshutdown event iscalled immediately after all of the finish event handlers finish processing, and is the last opportunity

    to do any work before the script terminates. Most likely, you will not have a need to use either ofthese events.

  • 8/12/2019 l4 Offline Doc

    38/310

    Routing Basic Routing

    Route Parameters

    Route Filters

    Named Routes

    Route Groups

    Sub-Domain Routing

    Route Prefixing

    Route Model Binding

    Throwing 404 Errors Routing To Controllers

    Basic Routing

    Most of the routes for your application will be defined in the app/routes.php file. The simplestLaravel routes consist of a URI and a Closure callback.

    Basic GET Route

    Route::get('/', function()

    {

    return 'Hello World';

    });

    Basic POST Route

    Route::post('foo/bar', function()

    {

    return 'Hello World';

    });

  • 8/12/2019 l4 Offline Doc

    39/310

    Routing 27

    Registering A Route For Multiple Verbs

    Route::match(array('GET', 'POST'), '/', function()

    {

    return 'Hello World';

    });

    Registering A Route Responding To Any HTTP Verb

    Route::any('foo', function()

    {

    return 'Hello World';

    });

    Forcing A Route To Be Served Over HTTPS

    Route::get('foo', array('https', function()

    {

    return 'Must be over HTTPS';

    }));

    Often, you will need to generate URLs to your routes, you may do so using the URL::tomethod:

    $url = URL::to('foo');

  • 8/12/2019 l4 Offline Doc

    40/310

    Routing 28

    Route Parameters

    Route::get('user/{id}', function($id)

    {

    return 'User '.$id;

    });

    Optional Route Parameters

    Route::get('user/{name?}', function($name = null)

    {

    return $name;

    });

    Optional Route Parameters With Defaults

    Route::get('user/{name?}', function($name = 'John')

    {

    return $name;

    });

    Regular Expression Route Constraints

  • 8/12/2019 l4 Offline Doc

    41/310

    Routing 29

    Route::get('user/{name}', function($name)

    {

    //})

    ->where('name', '[A-Za-z]+');

    Route::get('user/{id}', function($id)

    {

    //

    })

    ->where('id', '[0-9]+');

    Passing An Array Of Wheres

    Of course, you may pass an array of constraints when necessary:

    Route::get('user/{id}/{name}', function($id, $name)

    {

    //

    })

    ->where(array('id' => '[0-9]+', 'name' => '[a-z]+'))

    Defining Global Patterns

    If you would like a route parameter to always be constrained by a given regular expression, youmay use the patternmethod:

    Route::pattern('id', '[0-9]+');

    Route::get('user/{id}', function($id)

    {

    // Only called if {id} is numeric.

  • 8/12/2019 l4 Offline Doc

    42/310

    Routing 30

    });

    Accessing A Route Parameter Value

    If you need to access a route parameter value outside of a route, you may use the Route::inputmethod:

    Route::filter('foo', function()

    {

    if (Route::input('id') == 1)

    {

    //}

    });

    Route Filters

    Route filters provide a convenient way of limiting access to a given route, which is useful for creatingareas of your site which require authentication. There are several filters included in the Laravel

    framework, including an authfilter, an auth.basicfilter, a guestfilter, and a csrffilter. These arelocated in the app/filters.phpfile.

    Defining A Route Filter

    Route::filter('old', function()

    {

    if (Input::get('age') < 200)

    {

    return Redirect::to('home');

    }

    });

    If a response is returned from a filter, that response will be considered the response to the requestand the route will not be executed, and any afterfilters on the route will also be cancelled.

  • 8/12/2019 l4 Offline Doc

    43/310

    Routing 31

    Attaching A Filter To A Route

    Route::get('user', array('before' => 'old', function()

    {

    return 'You are over 200 years old!';

    }));

    Attaching A Filter To A Controller Action

    Route::get('user', array('before' => 'old', 'uses' => 'UserController@showProfile\'));

    Attaching Multiple Filters To A Route

    Route::get('user', array('before' => 'auth|old', function()

    {

    return 'You are authenticated and over 200 years old!';

    }));

    Specifying Filter Parameters

    Route::filter('age', function($route, $request, $value)

    {

    //

    });

    Route::get('user', array('before' => 'age:200', function()

    {

    return 'Hello World';

  • 8/12/2019 l4 Offline Doc

    44/310

    Routing 32

    }));

    After filters receive a $responseas the third argument passed to the filter:

    Route::filter('log', function($route, $request, $response, $value)

    {

    //

    });

    Pattern Based Filters

    You may also specify that a filter applies to an entire set of routes based on their URI.

    Route::filter('admin', function()

    {

    //

    });

    Route::when('admin/*', 'admin');

    In the example above, the adminfilter would be applied to all routes beginning with admin/. Theasterisk is used as a wildcard, and will match any combination of characters.

    You may also constrain pattern filters by HTTP verbs:

    Route::when('admin/*', 'admin', array('post'));

    Filter Classes

    For advanced filtering, you may wish to use a class instead of a Closure. Since filter classes areresolved out of the applicationIoC Container, you will be able to utilize dependency injection inthese filters for greater testability.

  • 8/12/2019 l4 Offline Doc

    45/310

    Routing 33

    Defining A Filter Class

    class FooFilter {

    public function filter()

    {

    // Filter logic...

    }

    }

    Registering A Class Based Filter

    Route::filter('foo', 'FooFilter');

    Named Routes

    Named routes make referring to routes when generating redirects or URLs more convenient. Youmay specify a name for a route like so:

    Route::get('user/profile', array('as' => 'profile', function()

    {

    //

    }));

    You may also specify route names for controller actions:

  • 8/12/2019 l4 Offline Doc

    46/310

    Routing 34

    Route::get('user/profile', array('as' => 'profile', 'uses' => 'UserController@sho\

    wProfile'));

    Now, you may use the routes name when generating URLs or redirects:

    $url = URL::route('profile');

    $redirect = Redirect::route('profile');

    You may access the name of a route that is running via the currentRouteNamemethod:

    $name = Route::currentRouteName();

    Route GroupsSometimes you may need to apply filters to a group of routes. Instead of specifying the filter on eachroute, you may use a route group:

    Route::group(array('before' => 'auth'), function()

    {

    Route::get('/', function()

    {

    // Has Auth Filter

    });

    Route::get('user/profile', function()

    {

    // Has Auth Filter

  • 8/12/2019 l4 Offline Doc

    47/310

    Routing 35

    });

    });

    Sub-Domain Routing

    Laravel routes are also able to handle wildcard sub-domains, and pass you wildcard parameters fromthe domain:

    Registering Sub-Domain Routes

    Route::group(array('domain' => '{account}.myapp.com'), function()

    {

    Route::get('user/{id}', function($account, $id)

    {

    //

    });

    });

    Route Prefixing

    A group of routes may be prefixed by using the prefixoption in the attributes array of a group:

    Prefixing Grouped Routes

  • 8/12/2019 l4 Offline Doc

    48/310

    Routing 36

    Route::group(array('prefix' => 'admin'), function()

    {

    Route::get('user', function()

    {

    //

    });

    });

    Route Model Binding

    Model binding provides a convenient way to inject model instances into your routes. For example,instead of injecting a users ID, you can inject the entire User model instance that matches thegiven ID. First, use the Route::modelmethod to specify the model that should be used for a givenparameter:

    Binding A Parameter To A Model

    Route::model('user', 'User');

    Next, define a route that contains a {user}parameter:

    Route::get('profile/{user}', function(User $user)

    {

    //

    });

    Since we have bound the {user}parameter to the Usermodel, a Userinstance will be injected intothe route. So, for example, a request to profile/1will inject the Userinstance which has an ID of1.

  • 8/12/2019 l4 Offline Doc

    49/310

    Routing 37

    Note: If a matching model instance is not found in the database, a 404 error will be thrown.

    If you wish to specify your own not found behavior, you may pass a Closure as the third argumentto themodelmethod:

    Route::model('user', 'User', function()

    {

    throw new NotFoundException;

    });

    Sometimes you may wish to use your own resolver for route parameters. Simply use the Route::bindmethod:

    Route::bind('user', function($value, $route)

    {

    return User::where('name', $value)->first();

    });

    Throwing 404 Errors

    There are two ways to manually trigger a 404 error from a route. First, you may use the App::abortmethod:

    App::abort(404);

    Second, you may throw an instance ofSymfony\Component\HttpKernel\Exception\NotFoundHttpExceptio

    More information on handling 404 exceptions and using custom responses for these errors may befound in theerrorssection of the documentation.

  • 8/12/2019 l4 Offline Doc

    50/310

    Routing 38

    Routing To Controllers

    Laravel allows you to not only route to Closures, but also to controller classes, and even allows the

    creation ofresource controllers.See the documentation onControllersfor more details.

  • 8/12/2019 l4 Offline Doc

    51/310

    Requests & Input Basic Input

    Cookies

    Old Input

    Files

    Request Information

    Basic Input

    You may access all user input with a few simple methods. You do not need to worry about the HTTPverb used for the request, as input is accessed in the same way for all verbs