Book Image

Mastering Laravel

By : Christopher Pecoraro
Book Image

Mastering Laravel

By: Christopher Pecoraro

Overview of this book

<p>PHP continues to revive and Laravel is at its forefront. Laravel follows modern PHP's object-oriented best practices and reduces time-to-market, enabling you to build robust web and API-driven mobile applications that can be automatically tested and deployed.</p> <p>With this book you will learn how to rapidly develop software applications using the Laravel 5 PHP framework.</p> <p>This book walks you through the creation of an application, starting with behavior-driven design of entities. You'll explore various aspects of modern software including the RESTful API, and will be introduced to command bus. Laravel's annotations package is also explained and demonstrated. Finally, the book closes with a demonstration of different ways to deploy and scale your applications.</p>
Table of Contents (17 chapters)
Mastering Laravel
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
3
Building Services, Commands, and Events
Index

Preface

PHP, a free and open source programming language, is continuing renaissance and Laravel is at the forefront. Laravel 5 is proving to be the most usable framework for novice and expert programmers alike. Following modern PHP's object-oriented best practices, reduce the time to market and build robust web and API-driven mobile applications that can be automatically tested and deployed.

You will learn how to rapidly develop software applications using the Laravel 5 PHP framework.

What this book covers

Chapter 1, Designing Done Right with phpspec, speaks about how to configure Laravel 5 for phpspec to perform modern unit testing, to use phpspec to design classes, and to perform unit and functional testing.

Chapter 2, Automating Tests – Migrating and Seeding Your Database, covers database migrations, the mechanics behind them and how to create a seed for testing.

Chapter 3, Building Services, Commands, and Events, talks about Model-View-Controller and how has evolved into services, commands, and events to decouple code and practice separation of concerns.

Chapter 4, Creating RESTful APIs, takes you through the creation of a RESTful API: the basic CRUD operations (create, read, update, and delete), as well as discussing some best practices and hypermedia controls (HATEOAS).

Chapter 5, Using the Form Builder, takes you to the web interface side of things and shows you how to take advantage of the some of the newest features of Laravel 5 to create web forms. Reversed routing will be discussed here as well.

Chapter 6, Taming Complexity with Annotations, focuses on annotations. The routes.php file easily becomes messy when an application grows in complexity. Using annotations inside of controllers, code legibility is drastically increased; however, there are some disadvantages in addition to the advantages.

Chapter 7, Filtering Requests with Middleware, shows you how to create reusable filters that can be called either before or after the controllers.

Chapter 8, Querying the Database with the Eloquent ORM, helps you learn how to use an ORM in a way to reduce the probability of errors in coding, increase the security and reduction of SQL-injection probability, and also learn how to deal with the limits of the Eloquent ORM.

Chapter 9, Scaling Laravel, speaks about scaling an application to move it into a cloud-based architecture. The read/write master/slave configuration is discussed and the reader is guided through the configuration.

Chapter 10, Building, Compiling, and Testing with Elixir, introduces Elixir. Elixir is based on gulp, which is a task runner and is a series of build scripts that automates common tasks in the Laravel software development workflow.

What you need for this book

We'll need the following software:

  • Apache/Nginx

  • PHP 5.4 or greater

  • MySQL or similar

  • Composer

  • phpspec

  • Node.js

  • npm

Who this book is for

If you are an experienced novice or a capable PHP programmer who has a basic understanding of the concepts of modern PHP (at least version 5.4), then this book is ideal for you.

Basic object-oriented programming and database knowledge is expected. You should already know your way around Laravel or will have at least experimented with the framework.

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 are shown as follows: “ The new artisan command is run as follows”

A block of code is set as follows:

protected function schedule(Schedule $schedule)
    {
        $schedule->command('inspire')
             ->hourly();
        $schedule->command('manage:waitinglist')
            ->everyFiveMinutes();

    }

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

$ php artisan schedule:run

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: “ The migration table now appears, as shown in the following screenshot.”

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 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 , 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.

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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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 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

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 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

If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.