O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Laravel Design Patterns and Best Practices

Book Description

Enhance the quality of your web applications by efficiently implementing design patterns in Laravel

In Detail

This book covers how to develop different applications and solve recurring problems using Laravel 4 design patterns. It will walk you through the widely used design patterns—the Builder (Manager) pattern, Factory pattern, Repository pattern, and Strategy pattern—and will empower you to use these patterns while developing various applications with Laravel. This book will help you find stable and acceptable solutions, thereby improving the quality of your applications. Throughout the course of the book, you will be introduced to a number of clear, practical examples about PHP design patterns and their usage in various projects. You will also get acquainted with the best practices for Laravel that will greatly reduce the probability of introducing errors into your web applications.

By the end of the book, you will be accustomed to the best practices and the important design patterns used in Laravel to make a great website.

What You Will Learn

  • „Learn about the design pattern fundamentals in OOP programming
  • „Get acquainted with the structure of MVC architecture and use objects in your applications
  • Discover Laravel's approach to MVC and its benefits
  • Work with various design patterns used in Laravel such as the Builder (Manager) pattern, Factory pattern, Repository pattern, and Strategy pattern
  • Create and maintain web applications using Laravel best practices
  • „Implement PHP design patterns to solve commonly occurring problems

Downloading the example code for this book. 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.

Table of Contents

  1. Laravel Design Patterns and Best Practices
    1. Table of Contents
    2. Laravel Design Patterns and Best Practices
    3. Credits
    4. About the Authors
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
      7. Downloading the example code
        1. Errata
        2. Piracy
        3. Questions
    8. 1. Design and Architectural Pattern Fundamentals
      1. Design patterns
        1. Elements of design patterns
        2. Classification of design patterns
          1. Creational patterns
          2. Structural patterns
          3. Behavioral patterns
      2. What is MVC?
      3. Summary
    9. 2. Models in MVC
      1. What is a Model?
      2. Purposes of the Model
      3. Model instances
      4. The Model in Laravel
        1. Fluent Query Builder
        2. Eloquent ORM
          1. Relationships
          2. Mass assignment
          3. Soft deleting
          4. Eager loading
          5. Timestamps
          6. Query scopes
          7. Accessors and mutators
          8. Model events
          9. Model observers
        3. Migrations
        4. Database seeders
      5. Summary
    10. 3. Views in MVC
      1. What is a View?
      2. View objects
      3. View in Laravel
      4. Summary
    11. 4. Controllers in MVC
      1. What is a Controller?
      2. The purpose of the Controller
      3. Controllers in Laravel
        1. Routes
      4. Using Controllers inside folders
      5. Summary
    12. 5. Design Patterns in Laravel
      1. The Builder (Manager) pattern
        1. The need for the Builder (Manager) pattern
      2. The Factory pattern
        1. The need for the Factory pattern
      3. The Repository pattern
        1. The need for the Repository pattern
      4. The Strategy pattern
        1. The need for the Strategy pattern
      5. The Provider pattern
      6. The Facade pattern
      7. Summary
    13. 6. Best Practices in Laravel
      1. Basic practices
      2. Advanced practices
        1. The Factory pattern
        2. The Builder pattern
        3. The Strategy pattern
        4. The Repository pattern
      3. Summary
    14. Index