41,99 €
A recipe-based book to help you efficiently create amazing PHP-based applications with Laravel 5.x
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.
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 toys, 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.
This book will have a practical recipe-based approach with dedicated recipes on your daily Laravel tasks (as well as on more advanced issues) that will help you become a pro with Laravel 5.x
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 238
Veröffentlichungsjahr: 2016
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
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
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!
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.
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 <[email protected]> for more details.
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.
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.
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.
The entire list of this and the installation process has been explained in Chapter 1 of the Book.
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.
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:
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.
This section contains the steps required to follow the recipe.
This section usually consists of a detailed explanation of what happened in the previous section.
This section consists of additional information about the recipe in order to make the reader more knowledgeable about the recipe.
This section provides helpful links to other useful information for the recipe.
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 are shown as follows: "You will need a terminal application, access to the Git command"
A block of code is set as follows:
Any command-line input or output is written as follows:
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "First navigate to GitHub, Settings, and Personal access tokens."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <[email protected]>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.
You can download the code files by following these steps:
You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Laravel-5x-Cookbook/. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at <[email protected]> with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
If you have a problem with any aspect of this book, you can contact us at <[email protected]>, and we will do our best to address the problem.
In this chapter, we will cover the following topics:
In this chapter, we will cover installing and setting up Laravel and Homestead. As I have often said in this book, the online Laravel docs are great, and I will refer to them as needed. This book should be regarded as a complement to the official documentation, expanding on the explanations found there and adding some tips and tricks for everyday use. Also, I will show a number of shortcuts to help speed up your workflow. Finally, I will touch on Gulp and Elixir.
This section will work off the existing Laravel docs to make sure your Homestead is set up correctly, as well as give you some background as to what is going on.
You will need a terminal application, access to the Git command, and decent Internet. As for the terminal on Mac, I suggest iTerm, available at https://www.iterm2.com/; it really is a nice tool for something you are going to use quite often. For Windows, git for Windowshttps://git-for-windows.github.io/ got me going quickly both for git and a Bash such as terminal. Linux has a nice terminal to begin with, and installing git is easy. As far as Vagrant and VirtualBox are concerned, I will link you to the related sites since they do a good job at explaining how to install each of them on your system.
The following are the steps to set up Homestead:
At this point, Vagrant will be ready to use at the command line:
You will not really need to open VirtualBox.
For Windows users, this link helped me a lot to get started with Homestead: http://blog.teamtreehouse.com/laravel-homestead-on-windows.
On a Mac, this will look like—/Users/alfrednutile/Code.
From here, the online docs do a great job of getting you going on the final Homestead installation and setup—https://laravel.com/docs/5.2/homestead.When done, you will have the Homestead.yml configuration information in the ~/.homestead folder to modify as needed. On Mac, this would be /Users/alfrednutile/.homestead/Homestead.yml.
Laravel Docs talk about shortcuts in the Daily Usage section at https://laravel.com/docs/5.2/homestead#daily-usage.
Also, you should have made a new folder called ~/Code to be the base folder for all your projects. For example, my folder looks like this:
You can have multiple applications within your code folder. In this example, app1 is the root folder for the app1 application, and app2 is the root folder for the app2 code. Keep in mind that the Vagrant box will later on mount this Code folder into the /home/vagrant/Code folder inside the Vagrant client.
I do my migration and PHPUnit work inside Homestead using the ssh shortcut that the online documents show you. But I do a lot of work outside Homestead inside the Code/app1 directory, such as all the Git commands and much of composer. This creates a much faster workflow for the file intense commands.
You can, of course, manually set up your own machine for Nginx, PHP, MySQL, and all the rest, but there are a lot of reasons why the preceding one is best. On a team or alone, having your environment contained like this makes upgrading your machine, going from desktop to laptop, pushing code to production, having up-to-date libraries for new apps and older libraries for legacy apps, and more so much easier.
In this section, we will download Laravel and set up our local site to use for the rest of our recipes taking advantage of Homestead.
We have Homestead installed. My home folder called ~/Code is where we will be working.
