Book Image

Laravel Application Development Cookbook

By : Terry Matula
Book Image

Laravel Application Development Cookbook

By: Terry Matula

Overview of this book

When creating a web application, there are many PHP frameworks from which to choose. Some are very easy to set up, and some have a much steeper learning curve. Laravel offers both paths. You can do a quick installation and have your app up-and-running in no time, or you can use Laravel's extensibility to create an advanced and fully-featured app.Laravel Application Development Cookbook provides you with working code examples for many of the common problems that web developers face. In the process, it will also allow both new and existing Laravel users to expand their knowledge of the framework.This book will walk you through all aspects of Laravel development. It begins with basic set up and installation procedures, and continues through more advanced use cases. You will also learn about all the helpful features that Laravel provides to make your development quick and easy. For more advanced needs, you will also see how to utilize Laravel's authentication features and how to create a RESTful API.In the Laravel Application Development Cookbook, you will learn everything you need to know about a great PHP framework, with working code that will get you up-and-running in no time.
Table of Contents (18 chapters)
Laravel Application Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sending an e-mail using Laravel and jQuery


When creating a contact form, we may choose to let the user send the form asynchronously. Using Laravel and jQuery, we can have the form submitted without needing the user to go to a different page.

Getting ready

For this recipe, we need a standard Laravel installation and our mail client properly configured. We can update our mail configuration in the app/config/mail.php file.

How to do it...

To complete this recipe, follow the given steps:

  1. In the views directory, create a file named emailform.php as shown in the following code:

      <!doctype html>
      <html lang="en">
      <head>
      <meta charset="utf-8">
      <title></title>
      <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
      </head>
      <body>
      <div id="container">
      <div id="error"></div>
      <form id="email-form">
      <label>To: </label>
      <input name="to" type="email"><br...