Laravel - my first framework
Laravel - my first framework
Companion for developers discovering Laravel PHP framework
About the Book
This book answers the following questions that newcomers to Laravel have:
- Why should I use Laravel?
- What is Composer?
- What is routing?
- How is MVC used in Laravel applications?
- What are sessions and how are they used?
- What is Eloquent ORM and how does it work?
While you read over 200 illustrated pages of the book and code samples you will gain understanding of Laravel framework, its components and concepts behind their usage.
Table of Contents
-
Introduction
- About the author
- Prerequisites
- Source Code
-
1. Meeting Laravel
-
1.1 Introducing Laravel 4 PHP framework
- 1.1.1 Laravel’s Expressive code
- 1.1.2 Laravel applications use Model-View-Controller pattern
- 1.1.3 Laravel was built by a great community
-
1.2 History of Laravel framework
- 1.2.1 State of PHP frameworks world before Laravel 4
- 1.2.2 Evolution of Laravel framework
-
1.3 Advantages of Using Laravel
- 1.3.1 Convention over configuration
- 1.3.2 Ready out of the box
- 1.3.3 Clear organization of all parts of the application
- 1.3.4 Built-in Authentication
- 1.3.5 Eloquent ORM – Laravel’s Active Record implementation
- 1.4 Summary
-
1.1 Introducing Laravel 4 PHP framework
-
2. Getting started for Development with Laravel
- 2.1 Development overview
- 2.2 Meeting Composer
- 2.3 Installing Laravel
- 2.4 Meeting Artisan: Laravel’s command line interface
-
2.5 Application structure overview
- 2.5.1 Files and folders in the root level of the application
- 2.5.2 Contents of the “app” folder
- 2.5.3 Configuration settings
-
2.6 Tutorial: building a website with Laravel
- 2.6.1 The big picture – development overview
- 2.6.2 Creating a new Laravel project
- 2.6.3 Configuring application settings
- 2.6.4 Specifying endpoints (routes) of the website
- 2.6.5 Creating the database structure and the model for the data
- 2.6.6 Filling the database with data
-
2.6.7 Creating HTML and Blade views
- 2.6.7.1 Building the layout
- 2.6.7.2 Building the template for the home page
- 2.6.7.3 Building the template for the services page
- 2.6.7.4 Building the template for the contact page
-
2.6.8 Displaying view templates from the routes
- 2.6.8.1 Connecting the home page route to the view template
- 2.6.8.2 Connecting the services page route to the view template
- 2.6.8.3 Connecting the contact page route to the view template
- 2.6.9 Adding validation to the contact form
- 2.6.10 Sending HTML email with Laravel
- 2.7 Summary
-
3. Routing
-
3.1 Introduction to Routing in Laravel
- 3.1.1 Structure of a basic route
- 3.1.2 Types of route requests
-
3.1.3 Routing example: login form
- 3.1.3.1 Building routing structure for the login form example
- 3.1.3.2 Showing HTML form and processing user input
-
3.2 Passing parameters to routes
-
3.2.1 Using route parameters
- 3.2.1.1 Passing more than one parameter
- 3.2.2 Route constraints
- 3.2.3 Making route parameters optional
-
3.2.1 Using route parameters
-
3.3 Route Filters
- 3.3.1 Attaching filters to routes
- 3.3.2 Creating custom filters
- 3.3.3 Adding multiple route filters
- 3.4 Grouping routes
-
3.5 Route responses
- 3.5.1 Showing output
-
3.5.2 Redirects
- 3.5.2.1 Redirecting to other URLs inside of the application
- 3.5.2.2 Redirecting to named routes
- 3.6 Summary
-
3.1 Introduction to Routing in Laravel
-
4. Views
-
4.1 Introducing views and templates
- 4.1.1 Views - application’s response to a request
- 4.1.2 Templates in Laravel, Blade
-
4.2 Creating and organizing views
-
- 4.2.0.1 Separating view templates in folders
-
-
4.3 Passing data to views
- 4.3.1 Using “View::make” arguments to pass data
- 4.3.2 Using method “with”
-
4.4 Blade template engine
-
4.4.1 Outputting and escaping data
- 4.4.1.1 Escaping Data
-
4.4.2 Using conditional statements and loops
- 4.4.2.1 Using conditional statements in the views with plain php
- 4.4.2.2 Using conditional statements in the views with blade
- 4.4.2.3 Using loops
-
4.4.1 Outputting and escaping data
-
4.5 Blade layouts
-
4.5.1 Creating and using a layout
- 4.5.1.1 Using layouts from views
- 4.5.1.2 Using method “@yield” to specify placeholders
- 4.5.2 Using sections
- 4.5.3 Nesting views by using @include
-
4.5.1 Creating and using a layout
- 4.6 Summary
-
4.1 Introducing views and templates
-
5. Understanding Controllers
- 5.1 Introducing controllers, the “C” in MVC
-
5.2 Default Controllers: BaseController and HomeController
- 5.2.1 Base controller (app/controllers/BaseController.php)
- 5.2.2 Home controller (app/controllers/HomeController.php)
-
5.3 Creating controllers
- 5.3.1 Creating a new controller: LoginController
- 5.3.2 Creating logic for the LoginController
- 5.3.3 Defining routing for LoginController
-
5.4 Using Basic, RESTful and Resource controllers
- 5.4.1 Creating and using Basic Controllers
- 5.4.2 Creating and using RESTful Controllers
-
5.4.3 Creating and using Resource Controllers
- 5.4.3.1 Creating resource controller with artisan command
-
5.5 Using controllers with routes
- 5.5.1 Routing to Basic Controllers
- 5.5.2 Routing to RESTful Controllers
- 5.5.3 Routing to Resource Controllers
-
5.6 Passing route parameters to controllers
- 5.6.1 Passing parameters to methods of a Basic Controller
- 5.6.2 Passing parameters to methods of a RESTful Controller
- 5.6.3 Passing parameters to methods of a Resource Controller
-
5.7 Using filters with controllers
- 5.7.1 Attaching filters to a controller
-
5.7.2 Applying filters to specific methods of a controller
- 5.7.2.1 Using the “on” keyword
- 5.7.2.2 Using the “except” and “only” keywords
- 5.8 Summary
-
6. Database operations
-
6.1 Introducing Database Operations in Laravel
- 6.1.1 Configuring database settings
-
6.1.2 Introducing Query Builder & Eloquent ORM
- 6.1.2.1 Query Builder
- 6.1.2.2 Eloquent ORM
-
6.2 Using Query Builder
-
6.2.1 Inserting records
- 6.2.1.1 Inserting a single record
- 6.2.1.2 Inserting multiple records
-
6.2.2 Retrieving records
- 6.2.2.1 Retrieving a single record
- 6.2.2.2 Retrieving all records in the table
- 6.2.2.3 Retrieving specific columns of all records in the table
- 6.2.2.4 Retrieving a limited number of records
-
6.2.3 Updating records
- 6.2.3.1 Updating specific records
- 6.2.3.2 Updating all records in the table
- 6.2.4 Deleting records
- 6.2.5 Deleting specific records
-
6.2.1 Inserting records
-
6.3 Filtering, sorting and grouping data
- 6.3.1 Query Chaining
-
6.3.2 Using “where” operator to filter data
- 6.3.2.1 Simple “where” query
- 6.3.2.2 Using “orWhere” operator
- 6.3.2.3 Using “whereBetween” operator
- 6.3.3 Using “orderBy” to sort data
- 6.3.4 Using “groupBy” to group data
-
6.4 Using Join Statements
- 6.4.1 Using Inner Join
- 6.4.2 Using Left Join
- 6.4.3 Using other types of Joins
- 6.5 Summary
-
6.1 Introducing Database Operations in Laravel
-
7. Eloquent ORM
-
7.1 Introducing Eloquent ORM
- 7.1.1 Introducing models
- 7.1.2 Understanding conventions
-
7.2 Creating and using models with Eloquent
-
- 7.2.0.1 Creating models
- 7.2.0.2 Using models
- 7.2.1 Inserting records
-
7.2.2 Retrieving records
- 7.2.2.1 Retrieving specific record by using query builder’s operator find()
- 7.2.2.2 Retrieving first record by using eloquent’s operator first()
- 7.2.2.3 Retrieving all records from a table using eloquent’s operator all()
- 7.2.2.4 Using operator get()
- 7.2.3 Updating records
- 7.2.4 Deleting records
-
-
7.3 Using relationships
- 7.3.1 One to one relationships
- 7.3.2 One to Many relationships
- 7.3.3 Many to Many relationships
- 7.3.4 Polymorphic relationships
- 7.3.5 Eager loading relations
-
7.4 Filtering data
- 7.4.1 Using query builder
- 7.4.2 Using query scopes
-
7.5 Working with retrieved data
- 7.5.1 Using collections to iterate through data
- 7.5.2 Converting results
- 7.5.3 Displaying data
- 7.6 Overriding conventions
- 7.7 Summary
-
7.1 Introducing Eloquent ORM
Other books by this author
Authors have earned$9,882,857writing, publishing and selling on Leanpub, earning 80% royalties while saving up to 25 million pounds of CO2 and up to 46,000 trees.
Learn more about writing on Leanpub
The Leanpub 45-day 100% Happiness Guarantee
Within 45 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers), EPUB (for phones and tablets) and MOBI (for Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them
Top Books
C++ Best Practices
Jason TurnerLevel up your C++, get the tools working for you, eliminate common problems, and move on to more exciting things!
Functional Design and Architecture
Alexander GraninSoftware Design in Functional Programming, Design Patterns and Practices, Methodologies and Application Architectures. How to build real software in Haskell with less efforts and low risks. The first complete source of knowledge.
OpenIntro Statistics
David Diez, Christopher Barr, Mine Cetinkaya-Rundel, and OpenIntroA complete foundation for Statistics, also serving as a foundation for Data Science.
Leanpub revenue supports OpenIntro (US-based nonprofit) so we can provide free desk copies to teachers interested in using OpenIntro Statistics in the classroom and expand the project to support free textbooks in other subjects.
More resources: openintro.org.
R Programming for Data Science
Roger D. PengThis book brings the fundamentals of R programming to you, using the same material developed as part of the industry-leading Johns Hopkins Data Science Specialization. The skills taught in this book will lay the foundation for you to begin your journey learning data science. Printed copies of this book are available through Lulu.
C++20
Rainer GrimmC++20 is the next big C++ standard after C++11. As C++11 did it, C++20 changes the way we program modern C++. This change is, in particular, due to the big four of C++20: ranges, coroutines, concepts, and modules.
I am a Software Engineer and I am in Charge
Alexis Monville and Michael DoyleI am a Software Engineer and I am in Charge is a real-world, practical book that helps you increase your impact and satisfaction at work no matter who you work with.
In the book, we will follow Sandrine, a fictional character who learns to think in a new way enabling her to take a different course of action.
Invest In Digital Health - The Medical Futurist's Guide
Dr. Bertalan MeskoArtificial Intelligence and Digital Health are booming. In this book, we explain why now it's a good time to invest in Digital Health and give recommendations on where to invest by looking at the top 24 technological trends we find the most promising.
Atomic Kotlin
Bruce Eckel and Svetlana IsakovaFor both beginning and experienced programmers! From the author of the multi-award-winning Thinking in C++ and Thinking in Java together with a member of the Kotlin language team comes a book that breaks the concepts into small, easy-to-digest "atoms," along with exercises supported by hints and solutions directly inside IntelliJ IDEA!
The Hundred-Page Machine Learning Book
Andriy BurkovEverything you really need to know in Machine Learning in a hundred pages.
Mastering STM32
Carmine NovielloWith more than 600 microcontrollers, STM32 is probably the most complete ARM Cortex-M platform on the market. This book aims to be the first guide around that introduces the reader to this exciting MCU portfolio from ST Microelectronics and its official CubeHAL.
Top Bundles
- #1
Software Architecture for Developers: Volumes 1 & 2 - Technical leadership and communication
2 Books
"Software Architecture for Developers" is a practical and pragmatic guide to modern, lightweight software architecture, specifically aimed at developers. You'll learn:The essence of software architecture.Why the software architecture role should include coding, coaching and collaboration.The things that you really need to think about before... - #2
The Future of Digital Health
6 Books
We put together the most popular books from The Medical Futurist to provide a clear picture about the major trends shaping the future of medicine and healthcare. Digital health technologies, artificial intelligence, the future of 20 medical specialties, big pharma, data privacy and how technology giants such as Amazon or Google want to conquer... - #3
Cisco CCNA 200-301 Complet
4 Books
Ce lot comprend les quatre volumes du guide préparation à l'examen de certification Cisco CCNA 200-301. - #4
CCDE Practical Studies (All labs)
3 Books
CCDE lab - #5
"The C++ Standard Library" and "Concurrency with Modern C++"
2 Books
Get my books "The C++ Standard Library" and "Concurrency with Modern C++" in a bundle. The first book gives you the details you should know about the C++ standard library; the second one dives deeper into concurrency with modern C++. In sum, you get more than 600 pages full of modern C++ and about 250 source files presenting the standard library... - #6
Modern Management Made Easy
3 Books
Read all three Modern Management Made Easy books. Learn to manage yourself, lead and serve others, and lead the organization. - #7
Programming with Ease
3 Books
Alle drei Bände der Serie Programming with Ease in einem Paket. Darin findest du alles, was ich dir zu den wichtigsten Phasen der Softwareentwicklung im Hinblick auf Clean Code Development für langfristig hohe Produktivität sagen kann.Im Band Slicing findest du die Anforderungsanalyse im Rahmen eines iterativ-inkrementellen Vorgehensmodells aus... - #8
Vagrant Ansible
2 Books
Unveil the power of Ansible and Vagrant with this bundle at a special price. You'll have everything you need to get started with Vagrant - learn the basics and how to create your virtual development environments, using Ansible as provisioner! About Vagrant Cookbook Vagrant Cookbook is a complete guide to get started with Vagrant and create your... - #9
Mastering Containers
2 Books
Docker and Kubernetes are taking the world by storm! These books will get you up-to-speed fast! Docker Deep Dive is over 400 pages long, and covers all objectives on the Docker Certified Associate exam.The Kubernetes Book includes everything you need to get up and running with Kubernetes! - #10
Growing Agile: The Complete Coach's Guide
7 Books
Growing Agile: Coach's Guide Series This bundle provides a collection of training and workshop plans for a variety of agile topics. The series is aimed at agile coaches, trainers and ScrumMasters who often find themselves needing to help teams understand agile concepts. Each book in the series provides the plans, slides, handouts and activity...