Laravel Application Development Cookbook
上QQ阅读APP看书,第一时间看更新

Preface

Laravel has become one of the fastest growing PHP frameworks ever. With its expressive syntax and excellent documentation, it's easy to get a fully functioning web application up-and-running in very little time. Additionally, the use of modern PHP features makes Version 4 of Laravel very easy to customize to our own needs and also makes it easy for us to create a highly complex site if need be. It's a perfect blend of the simple and advanced.

This book covers merely a fraction of all that Laravel is capable of. Think of it more as a starting point, with code examples to get things working. Then customize them, add to them, or combine them to create your own applications. The possibilities are endless.

One of the best things about Laravel is the community. If you're ever stuck on a problem and doing a Google search isn't helping, there are always people willing to help out. You can find helpful community members on IRC (#laravel on Freenode) or the forums (http://forums.laravel.io) or you can contact the many Laravel users on Twitter.

Happy Laravel-ing!

What this book covers

Chapter 1, Setting Up and Installing Laravel, covers various ways to get Laravel up-and-running.

Chapter 2, Using Forms and Gathering Input, shows many ways to use forms in Laravel. It covers using Laravel's form class as well as some basic validation.

Chapter 3, Authenticating Your Application, demonstrates how to authenticate users. We'll see how to use OAuth, OpenId, and various social networks for authentication.

Chapter 4, Storing and Using Data, covers all things data, including how to use data sources other than a MySQL database.

Chapter 5, Using Controllers and Routes for URLs and APIs, introduces various routing methods in Laravel and how to make a basic API.

Chapter 6, Displaying Your Views, demonstrates how views work in Laravel. We'll also incorporate the Twig templating system and Twitter Bootstrap.

Chapter 7, Creating and Using Composer Packages, explains how to use packages in our app as well as how to create our own package.

Chapter 8, Using Ajax and jQuery, provides different examples of how to use jQuery in Laravel and how to make asynchronous requests.

Chapter 9, Using Security and Sessions Effectively, covers topics about securing our application and how to use sessions and cookies.

Chapter 10, Testing and Debugging Your App, shows how to include unit testing in our app with PHPUnit and Codeception.

Chapter 11, Deploying and Integrating Third-party Services into Your Application, introduces a number of third-party services and how we can include them in our application.

What you need for this book

This book basically requires a working LAMP stack (Linux, Apache, MySQL, and PHP). The web server is Apache 2, which can be found at http://httpd.apache.org. The recommended database server is MySQL 5.6, which can be downloaded from http://dev.mysql.com/downloads/mysql. The recommended minimum PHP version is 5.4, which is found at http://php.net/downloads.php.

For an all-in-one solution, there is also a WAMP server (http://www.wampserver.com/en) or XAMMP (http://www.apachefriends.org/en/xampp.html) for Windows or MAMP (http://www.mamp.info/en/mamp-pro) for Mac OS X.

Who this book is for

This book is designed for people with an intermediate knowledge of PHP. It would also be helpful to know the basics of another PHP framework or Version 3 of Laravel. Some knowledge of the MVC structure and object-oriented programming would also be beneficial.

Conventions

In this book, you will find a number of styles of text 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: "Then, we use the artisan command to generate a new key for us, and it's automatically saved in the correct file".

A block of code is set as follows:

Route::get('accounts', function()
{
  $accounts = Account::all();
  return View::make('accounts')->with('accounts', $accounts);
});

Any command-line input or output is written as follows:

  php artisan key:generate

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "After logging in to Pagodabox, click on the New Application tab".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title via 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 on www.packtpub.com/authors.

Customer support

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.

Downloading the example code

You can download the example code files for all Packt books you have purchased 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.

Errata

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 would 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 on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from http://www.packtpub.com/support.

Piracy

Piracy of copyright 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 with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.