Laravel 5.x Cookbook
()
About this ebook
- Leverage the amazing new features of Laravel 5.x to create cutting-edge responsive PHP applications.
- Create apps with interoperability features and extend these features to your existing applications as well.
- Over 60 recipes that combine tried and tested Laravel tips for getting your app working.
The ideal target audience for this book is PHP developers who have some basic PHP programming knowledge. No previous experience with Laravel is required for this book.
Related to Laravel 5.x Cookbook
Related ebooks
Meteor: Full-Stack Web Application Development Rating: 0 out of 5 stars0 ratingsLearning Bootstrap Rating: 1 out of 5 stars1/5Laravel Application Development Cookbook Rating: 0 out of 5 stars0 ratingsPHP Ajax Cookbook Rating: 2 out of 5 stars2/5Apache Solr PHP Integration Rating: 0 out of 5 stars0 ratingsPHP 7: Real World Application Development Rating: 0 out of 5 stars0 ratingsAngularJS Web Application Development Cookbook Rating: 0 out of 5 stars0 ratingsASP.NET Core 3 and React: Hands-On full stack web development using ASP.NET Core, React, and TypeScript 3 Rating: 0 out of 5 stars0 ratingsBootstrap By Example Rating: 0 out of 5 stars0 ratingsSpring Cookbook Rating: 0 out of 5 stars0 ratingsWeb Development with Django Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsDart Cookbook Rating: 0 out of 5 stars0 ratingsFlask Framework Cookbook Rating: 5 out of 5 stars5/5Xamarin Mobile Development for Android Cookbook Rating: 0 out of 5 stars0 ratingsBootstrap 4 Cookbook Rating: 0 out of 5 stars0 ratingsSwift Cookbook Rating: 5 out of 5 stars5/5WebRTC Cookbook Rating: 0 out of 5 stars0 ratingsLaravel 5 Essentials Rating: 0 out of 5 stars0 ratingsPHP jQuery Cookbook Rating: 0 out of 5 stars0 ratingsJasmine JavaScript Testing - Second Edition Rating: 0 out of 5 stars0 ratingsVue.js 2 Cookbook Rating: 0 out of 5 stars0 ratingsNode Cookbook: Second Edition Rating: 3 out of 5 stars3/5Learning PHP Data Objects Rating: 5 out of 5 stars5/5Mastering MeteorJS Application Development Rating: 4 out of 5 stars4/5Express Web Application Development Rating: 3 out of 5 stars3/5Node Web Development, Second Edition Rating: 0 out of 5 stars0 ratingsNode.js Web Development - Third Edition Rating: 2 out of 5 stars2/5Learning Underscore.js Rating: 0 out of 5 stars0 ratings50 Recipes for Programming Node.js Rating: 3 out of 5 stars3/5PHP and MongoDB Web Development Beginner’s Guide Rating: 0 out of 5 stars0 ratings
Programming For You
Python: For Beginners A Crash Course Guide To Learn Python in 1 Week Rating: 4 out of 5 stars4/5Python Programming : How to Code Python Fast In Just 24 Hours With 7 Simple Steps Rating: 4 out of 5 stars4/5SQL QuickStart Guide: The Simplified Beginner's Guide to Managing, Analyzing, and Manipulating Data With SQL Rating: 4 out of 5 stars4/5Learn to Code. Get a Job. The Ultimate Guide to Learning and Getting Hired as a Developer. Rating: 5 out of 5 stars5/5Python Machine Learning By Example Rating: 4 out of 5 stars4/5Java for Beginners: A Crash Course to Learn Java Programming in 1 Week Rating: 5 out of 5 stars5/5HTML & CSS: Learn the Fundaments in 7 Days Rating: 4 out of 5 stars4/5SQL: For Beginners: Your Guide To Easily Learn SQL Programming in 7 Days Rating: 5 out of 5 stars5/5Learn SQL in 24 Hours Rating: 5 out of 5 stars5/5101 Amazing Nintendo NES Facts: Includes facts about the Famicom Rating: 4 out of 5 stars4/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Linux: Learn in 24 Hours Rating: 5 out of 5 stars5/5Pokemon Go: Guide + 20 Tips and Tricks You Must Read Hints, Tricks, Tips, Secrets, Android, iOS Rating: 5 out of 5 stars5/5Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5PYTHON: Practical Python Programming For Beginners & Experts With Hands-on Project Rating: 5 out of 5 stars5/5SQL All-in-One For Dummies Rating: 3 out of 5 stars3/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5C# 7.0 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsWeb Designer's Idea Book, Volume 4: Inspiration from the Best Web Design Trends, Themes and Styles Rating: 4 out of 5 stars4/5ReactJS by Example - Building Modern Web Applications with React Rating: 4 out of 5 stars4/5
Reviews for Laravel 5.x Cookbook
0 ratings0 reviews
Book preview
Laravel 5.x Cookbook - Alfred Nutile
Table of Contents
Laravel 5.x Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why Subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Sections
Getting ready
How to do it…
How it works…
There's more…
See also
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Setting Up and Installing Laravel
Introduction
Setting up Homestead
Getting ready
How to do it...
How it works...
There's more...
See also
Setting composer and PHP on your local machine for faster Workflows
Getting ready
How to do it...
How it works...
There's more...
See also
Setting up your first application in Homestead
Getting ready
How to do it...
How it works...
See also
Using .env for your local build
Getting ready
How to do it...
How it works...
See also
Using sequel pro and connecting to local and remote databases
How to do it...
How it works...
See also
Setting up Gulp and Elixir
How to do it...
How it works...
See also
2. Using Composer Packages
Introduction
Working with Composer install command and avoiding Composer update
Getting ready
How to do it...
How it works...
There's more...
See also
Making a provider
Getting ready
How to do it...
How it works...
See also
Using the Facade pattern
Getting ready
How to do it...
How it works...
See also
Using private packages
Getting ready
How to do it...
How it works...
See also
3. Routing
Introduction
Building an API / JSON based route for searching
Getting ready
How to do it...
How it works…
See also
Testing your route in PHPUnit
Getting ready
How to do it…
How it works…
See also
Building a view based route
Getting ready
How to do it…
How it works…
Testing your view based route in PHPUnit
Getting ready
How to do it…
How it works…
See also
Creating named routes
Getting ready
How to do it…
How it works…
See also
4. Building Views and Adding Style
Introduction
Organizing your Blade files
Getting ready
How to do it...
How it works...
See also
Installing a WrapBootStrap theme
Getting Started
How to do it…
How it works…
See also
Making your authentication pages
How to do it…
How it works…
Implementing an error message template
Getting started…
How to do it…
How it works…
Building your main search page
Getting started…
How to do it…
How it works…
See also
Adding a static page
Getting started…
How to do it…
How it works…
5. Working with Data
Introduction
Setting up users and running migrations
Getting ready
How to do it...
How it works...
See also
Altering a migration
Getting ready
How to do it....
How it works…
See also
Using factories for migrations and tests
Getting ready
How to do it…
How it works…
See also
Using a generator to scaffold your user wishlist area
Getting ready
How to do it…
How it works…
See also
Seeding so you can see how your app looks
Getting ready
How to do it…
How it works…
See also
Adding a file upload to user profile
Getting ready
How to do it…
How it works…
See also
Validating the file upload
Getting ready
How to do it…
How it works…
See also
Saving files to S3
Getting ready
How to do it…
How it works…
See also
6. Adding Angular to Your App
Introduction
Getting ready
How to do it...
How it works...
See also
Adding Angular search to our search page
Getting ready
How to do it…
How it works…
See also
Handling Angular and Ajax requests
Getting ready
How to do it…
How it works…
See also
Paginating our Angular results
Getting ready
How to do it…
How it works…
See also
Testing an Angular page with Behat
Getting ready
How to do it...
How it works…
See also
Creating a relationship with favorites
Getting ready
How to do it…
How it works…
See also
Building a favorites Ajax widget in Angular
Getting ready
How it works…
How to do it…
See also
Validating incoming input
Getting ready
How to do it…
How it works…
See also
Using the CORS protection
Getting ready
How to do it…
How it works…
See also
Using Elixir and Gulp to set up Angular
Getting ready
How to do it...
How it works...
See also
7. Authentication, Security, and Subscriptions
Introduction
Using policies and guard to protect user pages
Getting ready
How to do it...
How it works...
See also
Adding feature flags to hide features from users
Getting ready
How to do it…
How it works…
See also
Implementing Socialite to allow users to login with Facebook
Getting ready
How to do it…
How it works…
See also
Adding custom middleware to protect user admin area
Getting ready
How to do it…
How it works…
See also
Using Laravel to set up a subscription site
Getting ready
How to do it…
How it works…
See also
Creating an interface for the user to manage subscriptions
Getting ready
How to do it…
How it works…
Creating an admin interface for subscriptions
Getting ready
How to do it…
How it works…
8. Testing and Debugging Your Application
Introduction
Generating tests
Getting ready
How to do it...
How it works...
There's more...
See also
Using tests to think through your code TDT (Test Driven Thinking)
Getting ready
How to do it...
How it works...
See also
Getting your code onto GitHub
Getting ready
How to do it...
How it works...
See also
Using VCR for API testing
Getting ready
How to do it...
How it works...
See also
Using Travis to run tests with every push
Getting ready
How to do it...
How it works...
See also
Launching Gulp watch into your workflow
Getting ready
How to do it...
How it works...
See also
Using mockery to test your controllers
Getting ready
How to do it...
How it works…
See also
Troubleshooting your application
Getting ready
How to do it…
How it works…
9. Adding Advanced Features to Your App
Introduction
Building an Artisan command
Getting ready
How to do it...
How it works...
See also
Creating scheduler to notify users of new comics
Getting ready
How to do it…
How it works…
See also
Setting up e-mail notices
Getting ready
How to do it…
How it works…
See also
Adding clean URLS for the users profile page
Getting ready
How to do it…
How it works…
See also
Using pusher for live notifications
Getting ready
How to do it…
How it works…
See also
Adding a blog area to update users on new features
Getting ready
How to do it…
How it works…
See also
10. Deploying Your App
Introduction
Setting up Forge, AWS, and CodeDeploy
Getting ready
How to do it...
How it works…
See also
Setting up Travis to auto deploy when all is passing
Getting ready
How to do it…
How it works…
See also
Working with your .env file
Getting ready
How to do it…
How it works…
See also
Testing your app on Production with Behat
Getting ready
How to do it…
How it works…
See also
Making a composer package out of our client
Getting ready
How to do it…
How it works…
Index
Laravel 5.x Cookbook
Laravel 5.x Cookbook
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: August 2016
Production reference: 1290816
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78646-208-4
www.packtpub.com
Credits
Author
Alfred Nutile
Reviewer
Andrew Cavanagh
Commissioning Editor
Amarabha Banerjee
Acquisition Editor
Reshma Raman
Content Development Editor
Parshva Sheth
Technical Editor
Gebin George
Prajakta Mhatre
Copy Editor
Safis Editing
Project Coordinator
Sheejal Shah
Proofreader
Safis Editing
Indexer
Tejal Daruwale Soni
Graphics
Abhinash Sahu
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Alfred Nutile is an Enterprise Architect and Laravel lead based in Western Massachusetts. He's been working in the industry since the mid 90's. He started in PHP and MySQL back around that time and has worked with Ruby on Rails, Drupal, and Angular along the way. He introduced Laravel into an enterprise web stack, where he is currently contracted at, as Laravel proved itself as an amazing framework to build API's and Angular heavy application.
You can read more about him and checkout his blog at http://www.alfrednutile.info/ or follow him on Twitter at https://twitter.com/alnutile
Make sure to checkout the discount LaraCasts is offering those who buy the book!
Get a coupon for 50% on your first bill. Make it a yearly subscription and save $43!
Coupon Code: LaracastsLovesPackt
https://laracasts.com/signup?plan=yearly&coupon=LaracastsLovesPackt.
First let me say thanks to Taylor Otwell, I moved away from PHP to Rails and really was missing PHP only to be pointed to Laravel and have not looked back since. The framework makes my day to day work a pleasure and sometimes I feel guilty how easy it has made getting work done.
And Jeffrey Way for offering an amazing service that helped me to grow in understanding practical programming skills, keeping things simple, best practices and Laravel.
Of course I would like to thank Andrew Cavanagh for taking time to tediously edit this book. We have worked in the industry together for a number of years and currently both working on Laravel daily. And then there is my family who keeps me from getting too out of balanced since it is so easy to lose myself in the joy of building things on the computer!
About the Reviewer
Andrew Cavanagh is an experienced PHP developer whose background includes Drupal, Laravel, AngularJS, managing *nix servers (Apache and Nginx), project/budget/team management, and general haberdashy. He's currently focused on building enterprise web applications and tools. Andrew also enjoy cooking, amateur mycology, brewing, and long walks in imaginary places.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why Subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
Laravel is a prominent member of a new generation of web frameworks. It is one of the most popular PHP frameworks and is also free and an open source. Laravel 5 is a substantial upgrade with a lot of new and more efficient workflows, at the same time retaining the features that made Laravel wildly successful. It comes with plenty of architectural as well as design-based changes.
The book is a blend of numerous recipes that will give you all the necessary tips you need to build an application. It starts with basic installation and configuration tasks and will get you up-and-running in no time. You will learn to create and customize your PHP app and tweak and re-design your existing apps for better performance. You will learn to implement practical recipes to utilize Laravel's modular structure, the latest method injection, route caching, and interfacing techniques to create responsive modern-day PHP apps that stand on their own against other apps. Efficient testing and deploying techniques will make you more confident with your Laravel skills as you move ahead with this book.
Towards the end of the book, you will understand a number of add-ons and new features essential to finalize your application to make it ready for subscriptions. You will be empowered to get your application out to the world.
What this book covers
Chapter 1, Setting Up and Installing Laravel, helps you setup Laravel on your local machine.
Chapter 2, Using Composer Packages, this will cover some key concepts to getting comfortable with this amazing tool.
Chapter 3, Routing, the heart of any web framework, this will dig into some use cases of Laravel routing.
Chapter 4, Building Views and Adding Style, digging into Blade, Bootstrap and other key areas to building an app.
Chapter 5, Working with Data, covers factories, seeding and a look at a scaffolding library to save you work.
Chapter 6, Adding Angular to Your App, all the key concepts to getting going with Angular in your application.
Chapter 7, Authentication, Security, and Subscriptions, covers protecting your application, building a subscription service, and an admin interface.
Chapter 8, Testing and Debugging Your Application, shows you how to think about your code using tests, having TravisCI run your tests on every push to Github, and more.
Chapter 9, Adding Advanced Features to Your App, teaches you about building Artisan commands, Scheduler, Clean URLs and more.
Chapter 10, Deploying Your App, this chapter will dig into CodeDeploy, Forge, TravisCI and other recipes to deploy your application.
What you need for this book
The entire list of this and the installation process has been explained in Chapter 1 of the Book.
Who this book is for
The ideal target audience for this book is PHP developers who have some basic PHP programming knowledge. No previous experience with Laravel is required for this book.
Sections
In this book, you will find several headings that appear frequently (Getting ready, How to do it, How it works, There's more, and See also).
To give clear instructions on how to complete a recipe, we use these sections as follows:
Getting ready
This section tells you what to expect in the recipe, and describes how to set up any software or any preliminary settings required for the recipe.
How to do it…
This section contains the steps required to follow the recipe.
How it works…
This section usually consists of a detailed explanation of what happened in the previous section.
There's more…
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
See also
This section provides helpful links to other useful information for the recipe.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles