A free book covering the Laravel 5 Official Documentation. Laravel 5 Official Documentation Synced daily. A free ebook version of the Laravel 5.x Official Documentation. Gary Blankenship This book is for sale at http://leanpub.com/laravel-5 This version was published on 2016-02-27 Leanpub This is a Leanpub book. Leanpub empowers authors and publishers with the Lean Publishing process. Lean Publishing is the act of publishing an in-progress ebook using lightweight tools and many iterations to get reader feedback, pivot until you have the right book and build traction once you do. This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License Tweet This Book! Please help Gary Blankenship by spreading the word about this book on Twitter! 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 this hashtag on Twitter: https://twitter.com/search?q=#laravel Contents Contribution Guidelines 2 Release Notes 4 Support Policy 4 Laravel 5.3 {#releases-laravel-5.3} 4 Laravel 5.2 {#releases-laravel-5.2} 4 Laravel 5.1.11 {#releases-laravel-5.1.1l} 8 Laravel 5.1.4 {#releases-laravel-5. 1.4} 8 Laravel 5.1 {#releases-laravel-5.l} 8 Laravel 5.0 {#releases-laravel-5.0} 12 Laravel 4.2 20 Laravel 4.1 22 Upgrade Guide 25 Upgrading To 5.2.0 From 5.1 {#upgrade-upgrade-5.2.0} 25 Upgrading To 5.1.11 {#upgrade-upgrade-5. 1.11} 33 Upgrading To 5.1.0 {#upgrade-upgrade-5.1.0} 35 Upgrading To 5.0.16 {#upgrade-upgrade-5. 0.16} 40 Upgrading To 5.0 From 4.2 {#upgrade-upgrade-5.0} 41 Upgrading To 4.2 From 4.1 47 Upgrading To 4.1.29 From <= 4.1.x 49 Upgrading To 4.1.26 From <= 4.1.25 49 Upgrading To 4.1 From 4.0 51 Contribution Guide 53 Bug Reports 53 Core Development Discussion 54 Which Branch? 54 Security Vulnerabilities 54 Coding Style 54 Installation 56 Installation 56 Configuration 59 CONTENTS Introduction 59 Accessing Configuration Values 59 Environment Configuration 59 Configuration Caching 61 Maintenance Mode 61 Laravel Homestead 63 Introduction 63 Installation & Setup 64 Daily Usage 68 Basic Task List 71 Introduction 71 Installation 71 Prepping The Database 72 Routing 74 Building Layouts & Views 76 Adding Tasks 79 Deleting Tasks 83 Intermediate Task List 85 Introduction 85 Installation 85 Prepping The Database 86 Routing 91 Building Layouts & Views 94 Adding Tasks 97 Displaying Existing Tasks 99 Deleting Tasks 103 HTTP Routing 109 Basic Routing 109 Route Parameters 110 Named Routes Ill Route Groups 113 CSRF Protection 115 Route Model Binding 118 Form Method Spoofing 120 Accessing The Current Route 121 HTTP Middleware 122 Introduction 122 Defining Middleware 122 Registering Middleware 125 CONTENTS Middleware Parameters 127 Terminable Middleware 128 HTTP Controllers 130 Introduction 130 Basic Controllers 130 Controller Middleware 132 RESTful Resource Controllers 133 Dependency Injection & Controllers 134 Route Caching 137 HTTP Requests 138 Accessing The Request 138 Retrieving Input 141 HTTP Responses 147 Basic Responses 147 Other Response Types 149 Redirects 151 Response Macros 153 Views 155 Basic Usage 155 View Composers 157 Blade Templates 161 Introduction 161 Template Inheritance 161 Displaying Data 163 Control Structures 165 Stacks 167 Service Injection 168 Extending Blade 168 Request Lifecycle 170 Introduction 170 Lifecycle Overview 170 Focus On Service Providers 171 Application Structure 172 Introduction 172 The Root Directory 172 The App Directory 173 Service Providers 174 CONTENTS Introduction 174 Writing Service Providers 174 Registering Providers 177 Deferred Providers 177 Service Container 179 Introduction 179 Binding 180 Resolving 184 Container Events 185 Contracts 186 Introduction 186 Why Contracts? 186 Contract Reference 189 How To Use Contracts 190 Facades 192 Introduction 192 Using Facades 192 Facade Class Reference 194 Authentication 197 Introduction 197 Authentication Quickstart 198 Manually Authenticating Users 202 HTTP Basic Authentication 206 Resetting Passwords 207 Adding Custom Guards 210 Adding Custom User Providers 211 Events 214 Authorization 216 Introduction 216 Defining Abilities 216 Checking Abilities 218 Policies 222 Controller Authorization 227 Artisan Console 229 Introduction 229 Writing Commands 229 Command I/O 232 Registering Commands 238 CONTENTS Calling Commands Via Code 238 Laravel Cashier 241 Introduction 241 Subscriptions 243 Handling Stripe Webhooks 248 Single Charges 249 Invoices 250 Cache 252 Configuration 252 Cache Usage 253 Cache Tags 258 Adding Custom Cache Drivers 259 Events 261 Collections 263 Introduction 263 Creating Collections 263 Available Methods 264 Method Listing 264 Laravel Elixir 298 Introduction 298 Installation & Setup 298 Running Elixir 300 Working With Stylesheets 300 Working With Scripts 303 Copying Files & Directories 305 Versioning / Cache Busting 306 BrowserSync 307 Calling Existing Gulp Tasks 308 Writing Elixir Extensions 308 Encryption 311 Configuration 311 Basic Usage 311 Errors & Logging 313 Introduction 313 Configuration 313 The Exception Handler 314 HTTP Exceptions 315 Logging 316 CONTENTS Events 319 Introduction 319 Registering Events / Listeners 319 Defining Events 321 Defining Listeners 322 Firing Events 324 Broadcasting Events 325 Event Subscribers 330 Filesystem / Cloud Storage 333 Introduction 333 Configuration 333 Basic Usage 334 Custom Filesystems 338 Hashing 340 Introduction 340 Basic Usage 340 Helper Functions 342 Introduction 342 Available Methods 342 Method Listing 343 Arrays 343 Paths 350 Strings 352 URLs 357 Miscellaneous 359 Localization 365 Introduction 365 Basic Usage 366 Overriding Vendor Language Files 367 Mail 369 Introduction 369 Sending Mail 370 Mail & Local Development 375 Events 376 Package Development 378 Introduction 378 Service Providers 378 Routing 379 CONTENTS Resources 379 Public Assets 383 Publishing File Groups 384 Pagination 385 Introduction 385 Basic Usage 385 Displaying Results In A View 387 Converting Results To JSON 389 Queues 391 Introduction 391 Writing Job Classes 392 Pushing Jobs Onto The Queue 395 Running The Queue Listener 400 Dealing With Failed Jobs 403 Redis 407 Introduction 407 Basic Usage 408 Pub / Sub 410 Session 413 Introduction 413 Basic Usage 415 Adding Custom Session Drivers 418 Envoy Task Runner 421 Introduction 421 Writing Tasks 422 Running Tasks 425 Task Scheduling 427 Introduction 427 Defining Schedules 427 Task Output 430 Task Hooks 431 Testing 433 Introduction 433 Application Testing 434 Working With Databases 443 Mocking 449 Validation 453 CONTENTS Introduction 453 Validation Quickstart 453 Other Validation Approaches 458 Working With Error Messages 463 Available Validation Rules 466 Conditionally Adding Rules 473 Custom Validation Rules 475 Database: Getting Started 478 Introduction 478 Running Raw SQL Queries 479 Database Transactions 483 Using Multiple Database Connections 484 Database: Query Builder 485 Introduction 485 Retrieving Results 485 Selects 489 Joins 490 Unions 491 Where Clauses 491 Advanced Where Clauses 494 Ordering, Grouping, Limit, & Offset 495 Inserts 497 Updates 497 Deletes 498 Pessimistic Locking 499 Database: Migrations 500 Introduction 500 Generating Migrations 500 Migration Structure 501 Running Migrations 502 Writing Migrations 503 Database: Seeding 511 Introduction 511 Writing Seeders 511 Running Seeders 513 Eloquent: Getting Started 515 Introduction 515 Defining Models 515 Retrieving Multiple Models 519 CONTENTS Retrieving Single Models / Aggregates 521 Inserting & Updating Models 522 Deleting Models 526 Query Scopes 530 Events 535 Eloquent: Relationships 537 Introduction 537 Defining Relationships 537 Querying Relations 553 Inserting Related Models 558 Eloquent: Collections 564 Introduction 564 Available Methods 565 Custom Collections 565 Eloquent: Mutators 567 Introduction 567 Accessors & Mutators 567 Date Mutators 569 Attribute Casting 571 Eloquent: Serialization 574 Introduction 574 Basic Usage 574 Hiding Attributes From JSON 575 Appending Values To JSON 577 CONTENTS 1 The MIT License (MIT) Copyright ?? Taylor Otwell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ???Software???), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED ???AS IS???, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARIS...
Amiga789