Вы находитесь на странице: 1из 52

Building Real-Time Marvels with

Laravel: Create Dynamic and Interactive


Web Applications 1st Edition Sivaraj
Selvaraj
Visit to download the full and correct content document:
https://ebookmass.com/product/building-real-time-marvels-with-laravel-create-dynami
c-and-interactive-web-applications-1st-edition-sivaraj-selvaraj/
Building Real-Time
Marvels with Laravel
Create Dynamic and Interactive Web
Applications

Sivaraj Selvaraj
Building Real-Time Marvels with Laravel: Create Dynamic and Interactive Web
Applications
Sivaraj Selvaraj
Ulundurpettai, Tamil Nadu, India

ISBN-13 (pbk): 978-1-4842-9788-9 ISBN-13 (electronic): 978-1-4842-9789-6


https://doi.org/10.1007/978-1-4842-9789-6

Copyright © 2024 by Sivaraj Selvaraj


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodologies now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than using a trademark symbol
with every occurrence of a trademarked name, logo, or image, we use the names, logos, and images only in
an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors, the editors, nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Divya Modi
Development Editor: James Markham
Editorial Assistant: Divya Modi
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@
springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole
member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc
is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub (github.com/apress). For more detailed information, please visit https://www.apress.
com/gp/services/source-code.
Paper in this product is recyclable
This book is dedicated with profound love and gratitude to my beloved
family and dearest friends, who have stood as unwavering pillars of
support throughout my remarkable journey.
To my ever-supportive parents, whose boundless encouragement and
unwavering belief in my abilities have been the guiding light that led
me to this point.
To my dear sister and Sri Jaya Surya V, whose companionship and
camaraderie have filled every step of this journey with joy and
meaning.
Thank you all from the depths of my heart for being an integral part of
this incredible journey. This book is a testament to your unwavering
belief in me and a humble token of my deep appreciation for the
boundless love and support you have showered upon me.
With heartfelt appreciation and love.
Table of Contents
About the Author�������������������������������������������������������������������������������������������������xxvii

About the Technical Reviewer������������������������������������������������������������������������������xxix


Acknowledgments������������������������������������������������������������������������������������������������xxxi

Introduction��������������������������������������������������������������������������������������������������������xxxiii

Chapter 1: Understanding the Laravel Ecosystem���������������������������������������������������� 1


Introduction to the Laravel Ecosystem������������������������������������������������������������������������������������������ 2
MVC Pattern����������������������������������������������������������������������������������������������������������������������������� 3
Setting Up the Development Environment������������������������������������������������������������������������������������ 5
PHP (Hypertext Preprocessor)������������������������������������������������������������������������������������������������� 5
Web Server������������������������������������������������������������������������������������������������������������������������������ 5
Database (DB)�������������������������������������������������������������������������������������������������������������������������� 6
Composer�������������������������������������������������������������������������������������������������������������������������������� 6
Key Concepts and Principles of Laravel���������������������������������������������������������������������������������������� 9
Routing������������������������������������������������������������������������������������������������������������������������������������ 9
Controllers����������������������������������������������������������������������������������������������������������������������������� 10
Views������������������������������������������������������������������������������������������������������������������������������������� 13
Models����������������������������������������������������������������������������������������������������������������������������������� 14
Migrations����������������������������������������������������������������������������������������������������������������������������� 15
Middleware���������������������������������������������������������������������������������������������������������������������������� 16
Exploring the Laravel Ecosystem������������������������������������������������������������������������������������������������ 17
Laravel Packages������������������������������������������������������������������������������������������������������������������ 17
Summary������������������������������������������������������������������������������������������������������������������������������������ 19

v
Table of Contents

Chapter 2: Advanced Routing Techniques�������������������������������������������������������������� 21


Route Parameters and Wildcards������������������������������������������������������������������������������������������������ 22
Route Parameters������������������������������������������������������������������������������������������������������������������ 22
Wildcards������������������������������������������������������������������������������������������������������������������������������� 23
Route Model Binding������������������������������������������������������������������������������������������������������������������� 25
Route Binding������������������������������������������������������������������������������������������������������������������������ 25
Customizing Route Model Binding����������������������������������������������������������������������������������������� 27
Benefits of Route Model Binding������������������������������������������������������������������������������������������� 30
Route Caching����������������������������������������������������������������������������������������������������������������������������� 31
Ideal Cases for Enabling Route Caching�������������������������������������������������������������������������������� 32
Ideal Scenarios to Disable Route Caching����������������������������������������������������������������������������� 32
Enabling and Disabling Route Caching���������������������������������������������������������������������������������� 33
Benefits of Route Caching����������������������������������������������������������������������������������������������������� 33
Considerations and Limitations��������������������������������������������������������������������������������������������� 35
Middleware and Route Grouping������������������������������������������������������������������������������������������������� 36
Middleware���������������������������������������������������������������������������������������������������������������������������� 36
Route Grouping���������������������������������������������������������������������������������������������������������������������� 38
Benefits of Middleware and Route Grouping������������������������������������������������������������������������� 40
Route Model Binding for Polymorphic Relations������������������������������������������������������������������� 40
Route Model Binding with Polymorphic Relations����������������������������������������������������������������� 42
Customizing Polymorphic Route Model Binding�������������������������������������������������������������������� 43
Benefits of Route Model Binding for Polymorphic Relations������������������������������������������������� 44
Summary������������������������������������������������������������������������������������������������������������������������������������ 45

Chapter 3: Database Management and Eloquent ORM������������������������������������������� 47


Working with Database Migrations��������������������������������������������������������������������������������������������� 48
Database Migrations Provide Several Benefits��������������������������������������������������������������������� 48
Creating Migrations��������������������������������������������������������������������������������������������������������������� 49
Running Migrations��������������������������������������������������������������������������������������������������������������� 50
Modifying Migrations������������������������������������������������������������������������������������������������������������� 51
Migration Rollback and Refresh�������������������������������������������������������������������������������������������� 52

vi
Table of Contents

To Avoid Unwanted Consequences���������������������������������������������������������������������������������������� 53


Benefits of Database Migrations������������������������������������������������������������������������������������������� 54
Querying the Database with Eloquent����������������������������������������������������������������������������������������� 55
Retrieving Models������������������������������������������������������������������������������������������������������������������ 55
Query Constraints������������������������������������������������������������������������������������������������������������������ 56
Relationships������������������������������������������������������������������������������������������������������������������������� 56
Creating and Updating Models���������������������������������������������������������������������������������������������� 57
Deleting Models��������������������������������������������������������������������������������������������������������������������� 58
Lazy Loading and Eager Loading������������������������������������������������������������������������������������������� 58
Advantages of Eager Loading������������������������������������������������������������������������������������������������ 59
Cons of Eager Loading����������������������������������������������������������������������������������������������������������� 59
Advantages of Lazy Loading�������������������������������������������������������������������������������������������������� 60
Cons of Lazy Loading������������������������������������������������������������������������������������������������������������� 60
Choosing the Right Approach������������������������������������������������������������������������������������������������ 60
Eloquent Relationships: One-to-One, One-to-Many, and Many-to-Many������������������������������������ 61
One-to-One Relationship������������������������������������������������������������������������������������������������������� 62
One-to-Many Relationship����������������������������������������������������������������������������������������������������� 63
Many-to-Many Relationship�������������������������������������������������������������������������������������������������� 65
Advanced Eloquent Techniques: Polymorphic Relations and Query Scopes������������������������������� 67
Polymorphic Relations����������������������������������������������������������������������������������������������������������� 67
Query Scopes������������������������������������������������������������������������������������������������������������������������ 69
Advanced Eloquent Techniques Summary����������������������������������������������������������������������������� 70
Using Eloquent Collections and Serialization������������������������������������������������������������������������������ 70
Eloquent Collections�������������������������������������������������������������������������������������������������������������� 70
Serialization��������������������������������������������������������������������������������������������������������������������������� 71
Using Eloquent Collections and Serialization Summary�������������������������������������������������������� 72
Summary������������������������������������������������������������������������������������������������������������������������������������ 73

vii
Table of Contents

Chapter 4: Authentication and Authorization��������������������������������������������������������� 75


User Authentication: Registration, Login, and Logout����������������������������������������������������������������� 76
User Registration������������������������������������������������������������������������������������������������������������������� 76
User Login����������������������������������������������������������������������������������������������������������������������������� 80
User Logout��������������������������������������������������������������������������������������������������������������������������� 82
Authentication Guards and Providers������������������������������������������������������������������������������������������ 84
Authentication Guards����������������������������������������������������������������������������������������������������������� 85
Authentication Providers������������������������������������������������������������������������������������������������������� 86
Customizing Authentication Guards and Providers���������������������������������������������������������������� 88
Authentication Guards and Providers Summary�������������������������������������������������������������������� 89
Managing User Roles and Permissions��������������������������������������������������������������������������������������� 90
User Roles����������������������������������������������������������������������������������������������������������������������������� 90
User Permissions������������������������������������������������������������������������������������������������������������������� 92
Implementing Role-Based Access Control (RBAC)����������������������������������������������������������������� 94
Managing User Roles and Permissions Summary����������������������������������������������������������������� 96
Advanced Authorization Techniques: Gates and Policies������������������������������������������������������������ 97
Gates������������������������������������������������������������������������������������������������������������������������������������� 97
Policies���������������������������������������������������������������������������������������������������������������������������������� 98
Resource Controllers and Implicit Model Binding��������������������������������������������������������������� 100
Advanced Authorization Techniques Summary�������������������������������������������������������������������� 101
Summary���������������������������������������������������������������������������������������������������������������������������������� 101

Chapter 5: Building APIs with Laravel������������������������������������������������������������������ 103


Introduction to API Development����������������������������������������������������������������������������������������������� 104
Building RESTful APIs with Laravel������������������������������������������������������������������������������������������� 105
Resourceful Routing������������������������������������������������������������������������������������������������������������ 105
Folder Structure (API-Specific)�������������������������������������������������������������������������������������������� 109
API Authentication and Security������������������������������������������������������������������������������������������������ 110
Token-Based Authentication������������������������������������������������������������������������������������������������ 110
JWT Authentication�������������������������������������������������������������������������������������������������������������� 111
Best Practices for Using JWT in Laravel������������������������������������������������������������������������������ 111

viii
Table of Contents

API Throttling����������������������������������������������������������������������������������������������������������������������� 114


CORS (Cross-Origin Resource Sharing)������������������������������������������������������������������������������� 114
API Rate Limiting and Throttling����������������������������������������������������������������������������������������������� 115
Rate Limiting����������������������������������������������������������������������������������������������������������������������� 116
Throttling����������������������������������������������������������������������������������������������������������������������������� 116
Customizing Rate Limiting and Throttling��������������������������������������������������������������������������� 117
Handling Rate Limit Exceeded Responses�������������������������������������������������������������������������� 117
Handling API Errors and Exceptions������������������������������������������������������������������������������������������ 118
Exception Handling�������������������������������������������������������������������������������������������������������������� 118
Error Formatting������������������������������������������������������������������������������������������������������������������ 119
Error Responses������������������������������������������������������������������������������������������������������������������ 120
Logging and Debugging������������������������������������������������������������������������������������������������������� 120
Error Handling for Validation Errors������������������������������������������������������������������������������������� 121
Summary���������������������������������������������������������������������������������������������������������������������������������� 122

Chapter 6: Caching and Performance Optimization���������������������������������������������� 123


Understanding Laravel’s Cache System������������������������������������������������������������������������������������ 124
Cache Drivers���������������������������������������������������������������������������������������������������������������������� 124
Cache Tags�������������������������������������������������������������������������������������������������������������������������� 125
Cache Invalidation��������������������������������������������������������������������������������������������������������������� 126
Implementing Caching with Redis and Memcached����������������������������������������������������������������� 127
Configuring Redis as the Cache Driver�������������������������������������������������������������������������������� 128
Configuring Memcached as the Cache Driver��������������������������������������������������������������������� 128
Using Redis or Memcached for Caching������������������������������������������������������������������������������ 129
Cache Tagging and Cache Invalidation�������������������������������������������������������������������������������������� 131
Cache Tagging��������������������������������������������������������������������������������������������������������������������� 131
Retrieving Data by Tag��������������������������������������������������������������������������������������������������������� 133
Flushing Cache by Tag��������������������������������������������������������������������������������������������������������� 134
Optimizing Database Queries with Eager Loading�������������������������������������������������������������������� 135
Understanding Eager Loading��������������������������������������������������������������������������������������������� 136

ix
Table of Contents

Performance Optimization Techniques for Laravel Applications����������������������������������������������� 140


Code Optimization��������������������������������������������������������������������������������������������������������������� 140
Caching�������������������������������������������������������������������������������������������������������������������������������� 140
Database Optimization�������������������������������������������������������������������������������������������������������� 140
Lazy Loading vs. Eager Loading������������������������������������������������������������������������������������������ 141
Code Profiling and Monitoring��������������������������������������������������������������������������������������������� 141
Asset Optimization��������������������������������������������������������������������������������������������������������������� 141
HTTP Caching���������������������������������������������������������������������������������������������������������������������� 142
Optimized Configurations���������������������������������������������������������������������������������������������������� 142
Queue Optimization������������������������������������������������������������������������������������������������������������� 143
Server Optimization������������������������������������������������������������������������������������������������������������� 143
Summary���������������������������������������������������������������������������������������������������������������������������������� 144

Chapter 7: Advanced Middleware Techniques������������������������������������������������������ 145


Creating Custom Middleware���������������������������������������������������������������������������������������������������� 146
Creating Custom Middleware���������������������������������������������������������������������������������������������� 147
Middleware Pipeline and Terminable Middleware�������������������������������������������������������������������� 152
Middleware Pipeline������������������������������������������������������������������������������������������������������������ 153
Terminable Middleware������������������������������������������������������������������������������������������������������� 154
Illustration: Terminable Middleware������������������������������������������������������������������������������������ 155
Middleware Parameters and Dependencies����������������������������������������������������������������������������� 156
Middleware Parameters������������������������������������������������������������������������������������������������������ 156
Middleware Dependencies�������������������������������������������������������������������������������������������������� 158
Global Middleware vs. Route Middleware��������������������������������������������������������������������������������� 160
Global Middleware��������������������������������������������������������������������������������������������������������������� 161
Route Middleware��������������������������������������������������������������������������������������������������������������� 162
Middleware Best Practices and Performance Considerations�������������������������������������������������� 164
Keep Middleware Focused�������������������������������������������������������������������������������������������������� 164
Order of Middleware Matters���������������������������������������������������������������������������������������������� 165
Use Middleware Groups������������������������������������������������������������������������������������������������������ 165
Apply Middleware Selectively���������������������������������������������������������������������������������������������� 165
Middleware Parameters and Dependencies������������������������������������������������������������������������ 165

x
Table of Contents

Performance Considerations����������������������������������������������������������������������������������������������� 165


Error Handling and Exceptions�������������������������������������������������������������������������������������������� 166
Testing Middleware������������������������������������������������������������������������������������������������������������� 166
Summary���������������������������������������������������������������������������������������������������������������������������������� 166

Chapter 8: Real-Time Applications with Laravel�������������������������������������������������� 167


Real-Time Applications: An Overview��������������������������������������������������������������������������������������� 168
Building Real-Time Features with Laravel WebSockets������������������������������������������������������������ 169
Installation and Configuration��������������������������������������������������������������������������������������������� 169
Broadcasting Events with Laravel Echo������������������������������������������������������������������������������������ 171
Setting Up Laravel Echo������������������������������������������������������������������������������������������������������ 171
Configure Laravel Echo�������������������������������������������������������������������������������������������������������� 172
Listening for Events with Laravel Echo������������������������������������������������������������������������������� 175
Joining Channels����������������������������������������������������������������������������������������������������������������� 178
Handling Events������������������������������������������������������������������������������������������������������������������� 180
Presence Channels�������������������������������������������������������������������������������������������������������������� 180
Private Channels������������������������������������������������������������������������������������������������������������������ 183
Additional Features������������������������������������������������������������������������������������������������������������� 185
Creating Real-Time Notifications and Chat Applications����������������������������������������������������������� 188
Real-Time Notifications������������������������������������������������������������������������������������������������������� 188
Chat Applications����������������������������������������������������������������������������������������������������������������� 191
Real-Time Presence������������������������������������������������������������������������������������������������������������ 192
Private Messaging��������������������������������������������������������������������������������������������������������������� 195
Summary���������������������������������������������������������������������������������������������������������������������������������� 197

Chapter 9: Testing and Test-Driven Development������������������������������������������������� 199


Introduction to Testing in Laravel���������������������������������������������������������������������������������������������� 200
Writing Unit Tests with PHPUnit������������������������������������������������������������������������������������������������ 201
Generating a Test Class������������������������������������������������������������������������������������������������������� 201
Writing Test Methods����������������������������������������������������������������������������������������������������������� 201
Running Unit Tests��������������������������������������������������������������������������������������������������������������� 203
Mocking Dependencies������������������������������������������������������������������������������������������������������� 203
Best Practices for Unit Testing��������������������������������������������������������������������������������������������� 205
xi
Table of Contents

Testing HTTP Requests and Responses������������������������������������������������������������������������������������ 205


Writing Feature Tests����������������������������������������������������������������������������������������������������������� 206
Test-Driven Development (TDD) Workflow�������������������������������������������������������������������������������� 209
Write a Test�������������������������������������������������������������������������������������������������������������������������� 210
Run the Test������������������������������������������������������������������������������������������������������������������������� 210
Write the Code��������������������������������������������������������������������������������������������������������������������� 211
Run the Test Again��������������������������������������������������������������������������������������������������������������� 212
Refactor the Code (Optional)����������������������������������������������������������������������������������������������� 212
Advantages of Test-Driven Development (TDD)������������������������������������������������������������������� 213
Testing API Endpoints and Integrations������������������������������������������������������������������������������������� 214
Writing Feature Tests for API Endpoints������������������������������������������������������������������������������ 214
Summary���������������������������������������������������������������������������������������������������������������������������������� 218

Chapter 10: Queues and Job Scheduling�������������������������������������������������������������� 219


Introduction to Queues and Workers����������������������������������������������������������������������������������������� 220
Here’s How the Process Works�������������������������������������������������������������������������������������������� 220
Benefits of Using Queues and Workers������������������������������������������������������������������������������� 220
Laravel’s Integration of Queues and Workers���������������������������������������������������������������������� 221
Setting Up Queue Drivers and Connections������������������������������������������������������������������������������ 221
Choose a Queue Driver�������������������������������������������������������������������������������������������������������� 221
Configure the Queue Connection����������������������������������������������������������������������������������������� 222
Creating and Dispatching Jobs������������������������������������������������������������������������������������������������� 224
Create the Job Class������������������������������������������������������������������������������������������������������������ 225
Define the Job Logic������������������������������������������������������������������������������������������������������������ 225
Dispatch the Job������������������������������������������������������������������������������������������������������������������ 226
Illustration: Image Processing��������������������������������������������������������������������������������������������� 227
Managing Failed Jobs and Retries�������������������������������������������������������������������������������������������� 229
Understanding Failed Jobs�������������������������������������������������������������������������������������������������� 230
Scheduling Jobs with Laravel’s Task Scheduler����������������������������������������������������������������������� 233
Define the Scheduled Jobs in Kernel.php��������������������������������������������������������������������������� 233
Scheduling Artisan Commands�������������������������������������������������������������������������������������������� 233

xii
Table of Contents

Using Cron Expressions������������������������������������������������������������������������������������������������������� 234


Register the Scheduler in Cron�������������������������������������������������������������������������������������������� 235
Summary���������������������������������������������������������������������������������������������������������������������������������� 235

Chapter 11: Advanced Package Development������������������������������������������������������ 237


Introduction to Package Development in Laravel��������������������������������������������������������������������� 238
Setting Up the Package Structure��������������������������������������������������������������������������������������� 238
Creating Custom Service Providers������������������������������������������������������������������������������������������ 240
Create the Service Provider Class��������������������������������������������������������������������������������������� 240
Register Bindings and Services������������������������������������������������������������������������������������������� 240
Load the Service Provider��������������������������������������������������������������������������������������������������� 241
Additional Configuration (if Required)��������������������������������������������������������������������������������� 241
Using the Package’s Functionality��������������������������������������������������������������������������������������� 241
Publishing Configuration and Assets���������������������������������������������������������������������������������������� 241
Publishing Configuration����������������������������������������������������������������������������������������������������� 242
Publishing Assets���������������������������������������������������������������������������������������������������������������� 243
Registering the Assets��������������������������������������������������������������������������������������������������������� 244
Testing and Versioning Packages���������������������������������������������������������������������������������������������� 245
Testing Packages����������������������������������������������������������������������������������������������������������������� 245
Continuous Integration (CI)�������������������������������������������������������������������������������������������������� 249
Communication and Backward Compatibility���������������������������������������������������������������������� 253
Packaging and Distributing Laravel Packages�������������������������������������������������������������������������� 253
Package Structure��������������������������������������������������������������������������������������������������������������� 253
Create a Composer Package����������������������������������������������������������������������������������������������� 254
Publish Your Package���������������������������������������������������������������������������������������������������������� 255
Register Your Package��������������������������������������������������������������������������������������������������������� 255
Versioning and Tagging������������������������������������������������������������������������������������������������������� 255
Installation via Composer���������������������������������������������������������������������������������������������������� 256
Documentation�������������������������������������������������������������������������������������������������������������������� 256
Summary���������������������������������������������������������������������������������������������������������������������������������� 257

xiii
Table of Contents

Chapter 12: Performance Monitoring and Debugging������������������������������������������ 259


Profiling Laravel Applications���������������������������������������������������������������������������������������������������� 260
Laravel Debugbar���������������������������������������������������������������������������������������������������������������� 261
Xdebug�������������������������������������������������������������������������������������������������������������������������������� 263
Blackfire������������������������������������������������������������������������������������������������������������������������������ 265
Debugging Techniques and Tools���������������������������������������������������������������������������������������������� 267
Logging�������������������������������������������������������������������������������������������������������������������������������� 267
Dumping and Die Statements���������������������������������������������������������������������������������������������� 269
Exception Handling�������������������������������������������������������������������������������������������������������������� 271
IDE Debugging Tools������������������������������������������������������������������������������������������������������������ 273
Chrome DevTools����������������������������������������������������������������������������������������������������������������� 274
Performance Monitoring with Laravel Telescope���������������������������������������������������������������������� 274
Installation��������������������������������������������������������������������������������������������������������������������������� 274
Enabling Telescope�������������������������������������������������������������������������������������������������������������� 277
Identifying and Resolving Performance Bottlenecks���������������������������������������������������������������� 278
Monitoring and Profiling������������������������������������������������������������������������������������������������������ 278
Identify Bottlenecks������������������������������������������������������������������������������������������������������������� 278
Query Optimization�������������������������������������������������������������������������������������������������������������� 279
Caching�������������������������������������������������������������������������������������������������������������������������������� 279
Code Optimization��������������������������������������������������������������������������������������������������������������� 279
Use Queues for Background Processing����������������������������������������������������������������������������� 279
Profiling and Benchmarking������������������������������������������������������������������������������������������������ 280
Load Testing������������������������������������������������������������������������������������������������������������������������ 280
Optimize Asset Delivery������������������������������������������������������������������������������������������������������� 280
Scalability and Infrastructure���������������������������������������������������������������������������������������������� 280
Monitoring and Optimizing Application Security����������������������������������������������������������������������� 280
Keep Dependencies Up to Date������������������������������������������������������������������������������������������� 281
Implement Secure Authentication��������������������������������������������������������������������������������������� 281
Protect Routes and Sensitive Data�������������������������������������������������������������������������������������� 281
Sanitize and Validate User Input������������������������������������������������������������������������������������������ 281
Implement CSRF Protection������������������������������������������������������������������������������������������������� 281

xiv
Table of Contents

Secure Database Access����������������������������������������������������������������������������������������������������� 282


Implement Content Security Policies (CSPs)����������������������������������������������������������������������� 282
Protect Against Cross-Site Scripting (XSS)�������������������������������������������������������������������������� 282
Log and Monitor Security Events����������������������������������������������������������������������������������������� 282
Perform Security Audits and Penetration Testing���������������������������������������������������������������� 282
Educate Developers and Users�������������������������������������������������������������������������������������������� 283
Stay Updated with Security Practices��������������������������������������������������������������������������������� 283
Summary���������������������������������������������������������������������������������������������������������������������������������� 283

Chapter 13: Scaling Laravel Applications������������������������������������������������������������� 285


Scaling Strategies and Considerations������������������������������������������������������������������������������������� 286
Caching�������������������������������������������������������������������������������������������������������������������������������� 286
Database Optimization�������������������������������������������������������������������������������������������������������� 287
Queue System��������������������������������������������������������������������������������������������������������������������� 288
Monitoring and Scaling Metrics������������������������������������������������������������������������������������������� 288
Auto-scaling������������������������������������������������������������������������������������������������������������������������ 289
Caching HTTP Responses���������������������������������������������������������������������������������������������������� 290
Code Optimization��������������������������������������������������������������������������������������������������������������� 291
Load Balancing and Horizontal Scaling������������������������������������������������������������������������������������� 291
Load Balancing�������������������������������������������������������������������������������������������������������������������� 292
Horizontal Scaling��������������������������������������������������������������������������������������������������������������� 293
Database Scaling Techniques��������������������������������������������������������������������������������������������������� 294
Vertical Scaling�������������������������������������������������������������������������������������������������������������������� 295
Database Replication����������������������������������������������������������������������������������������������������������� 295
Database Sharding�������������������������������������������������������������������������������������������������������������� 296
Database Partitioning���������������������������������������������������������������������������������������������������������� 297
Database Caching���������������������������������������������������������������������������������������������������������������� 298
Caching and Content Delivery Networks (CDNs)����������������������������������������������������������������������� 299
Caching�������������������������������������������������������������������������������������������������������������������������������� 299
Content Delivery Networks (CDNs)�������������������������������������������������������������������������������������� 300
Implementing Queue Workers for High Traffic�������������������������������������������������������������������������� 303

xv
Table of Contents

Set Up the Queue Connection���������������������������������������������������������������������������������������������� 303


Using Docker Compose������������������������������������������������������������������������������������������������������� 305
Summary���������������������������������������������������������������������������������������������������������������������������������� 307

Chapter 14: Advanced Error Handling and Exception Management��������������������� 309


Customizing Error Pages and Handling Exceptions������������������������������������������������������������������ 310
Error Handling and Exception Management������������������������������������������������������������������������ 310
Overview of PHP Exceptions and Laravel’s Exception Handling Mechanism
Using Try-Catch Blocks�������������������������������������������������������������������������������������������������������� 311
Handling Exceptions in Laravel������������������������������������������������������������������������������������������� 313
Creating Custom Exception Classes and Throwing Exceptions to Manage
Specific Error Scenarios Effectively������������������������������������������������������������������������������������ 315
Customizing Error Pages����������������������������������������������������������������������������������������������������� 317
Demonstrating User-Friendly Error Pages with Relevant Information and Helpful
Instructions�������������������������������������������������������������������������������������������������������������������������� 319
Exception Logging and Reporting��������������������������������������������������������������������������������������������� 321
Configuring Laravel’s Logging Mechanism to Record Exceptions in Various Channels
(e.g., File, Database, Syslog) for Effective Error Tracking����������������������������������������������������� 321
Best Practices for Logging Exceptions with Context-­Specific Information and
Timestamps������������������������������������������������������������������������������������������������������������������������� 324
Logging and Monitoring Application Errors������������������������������������������������������������������������������� 325
Logging in Laravel��������������������������������������������������������������������������������������������������������������� 325
Centralized Logging with Laravel���������������������������������������������������������������������������������������� 332
Monitoring Application Errors���������������������������������������������������������������������������������������������� 335
Implementing Error Reporting and Alerting Systems���������������������������������������������������������������� 340
Error Reporting with Notifications��������������������������������������������������������������������������������������� 340
Real-Time Error Reporting with WebSockets���������������������������������������������������������������������� 346
Debugging Production Errors with Remote Logging and Tracing���������������������������������������������� 354
Remote Logging������������������������������������������������������������������������������������������������������������������ 354
Distributed Tracing�������������������������������������������������������������������������������������������������������������� 355
Error Alerting and Monitoring���������������������������������������������������������������������������������������������� 356
Live Debugging Tools����������������������������������������������������������������������������������������������������������� 357
Log Analysis and Error Investigation����������������������������������������������������������������������������������� 357
Postmortem Analysis and Resolution���������������������������������������������������������������������������������� 358

xvi
Table of Contents

Error Recovery and Graceful Degradation Strategies��������������������������������������������������������������� 358


Graceful Degradation����������������������������������������������������������������������������������������������������������� 358
Implementing Retry Mechanisms���������������������������������������������������������������������������������������� 361
Circuit Breaker Pattern�������������������������������������������������������������������������������������������������������� 367
Summary���������������������������������������������������������������������������������������������������������������������������������� 371

Chapter 15: Building Internationalized Applications with Laravel����������������������� 373


Introduction to Internationalization (i18n) and Localization (l10n)�������������������������������������������� 374
Internationalization (i18n)���������������������������������������������������������������������������������������������������� 374
Localization (l10n)��������������������������������������������������������������������������������������������������������������� 375
Key Components of Internationalization and Localization in Laravel���������������������������������� 375
Configuring Language Files and Translation Strings����������������������������������������������������������������� 376
Understanding Language Files�������������������������������������������������������������������������������������������� 376
Creating Language Files������������������������������������������������������������������������������������������������������ 376
Writing Translation Strings�������������������������������������������������������������������������������������������������� 377
Translating Database Content and User Input��������������������������������������������������������������������������� 379
Translating Database Content���������������������������������������������������������������������������������������������� 379
Create a Migration for the Translation Table������������������������������������������������������������������������ 380
Managing Locale-Specific Views and Assets���������������������������������������������������������������������������� 384
Organizing Locale-Specific Views��������������������������������������������������������������������������������������� 384
Handling Locale-Specific Assets����������������������������������������������������������������������������������������� 385
Localization of Asset URLs��������������������������������������������������������������������������������������������������� 386
Implementing Multilingual URLs and URL Routing�������������������������������������������������������������������� 387
Setting Up Multilingual Routes�������������������������������������������������������������������������������������������� 387
Generating Multilingual URLs���������������������������������������������������������������������������������������������� 389
Language Switching������������������������������������������������������������������������������������������������������������ 389
Summary���������������������������������������������������������������������������������������������������������������������������������� 390

Chapter 16: Advanced Frontend Development with Laravel��������������������������������� 391


Integrating Laravel with Modern Frontend Frameworks����������������������������������������������������������� 392
React����������������������������������������������������������������������������������������������������������������������������������� 392
Vue.js����������������������������������������������������������������������������������������������������������������������������������� 393

xvii
Table of Contents

Setting Up Laravel��������������������������������������������������������������������������������������������������������������� 394


Authentication and Authorization���������������������������������������������������������������������������������������� 410
Building Single-Page Applications (SPAs) with Laravel and JavaScript������������������������������������ 414
Set Up the Laravel Backend������������������������������������������������������������������������������������������������ 414
Enhancing User Experience with AJAX and Vue.js Components����������������������������������������������� 416
Install Vue.js������������������������������������������������������������������������������������������������������������������������� 417
Implementing Real-Time Updates with Laravel Echo and WebSockets������������������������������������ 420
Summary���������������������������������������������������������������������������������������������������������������������������������� 424

Chapter 17: Advanced Database Techniques and Optimization��������������������������� 425


Database Indexing and Query Optimization Techniques����������������������������������������������������������� 426
Database Indexing��������������������������������������������������������������������������������������������������������������� 427
Query Optimization�������������������������������������������������������������������������������������������������������������� 428
Additional Techniques���������������������������������������������������������������������������������������������������������� 430
Advanced Database Relationships and Performance Considerations��������������������������������������� 433
Types of Relationships��������������������������������������������������������������������������������������������������������� 434
Optimization Techniques����������������������������������������������������������������������������������������������������� 434
Implementing Database Replication and Failover Strategies��������������������������������������������������� 435
Database Replication����������������������������������������������������������������������������������������������������������� 435
Failover Strategies��������������������������������������������������������������������������������������������������������������� 437
Amazon RDS Multi-AZ with One Standby���������������������������������������������������������������������������� 438
Amazon RDS Multi-AZ with Two Readable Standbys���������������������������������������������������������� 440
Tip for Failover and Replication with AWS RDS������������������������������������������������������������������� 444
Database Partitioning and Sharding for Large-Scale Applications������������������������������������������� 444
Database Partitioning���������������������������������������������������������������������������������������������������������� 445
Database Sharding�������������������������������������������������������������������������������������������������������������� 446
Considerations��������������������������������������������������������������������������������������������������������������������� 448
Data Migrations and Schema Management in Production Environments��������������������������������� 449
Data Migrations������������������������������������������������������������������������������������������������������������������� 449
Schema Management��������������������������������������������������������������������������������������������������������� 451
Summary���������������������������������������������������������������������������������������������������������������������������������� 453

xviii
Table of Contents

Chapter 18: Laravel and Serverless Computing��������������������������������������������������� 455


Introduction to Serverless Architecture and Function as a Service (FaaS)������������������������������� 456
The Benefits of Serverless Architecture and FaaS�������������������������������������������������������������� 456
Integrating Laravel with Serverless Platforms�������������������������������������������������������������������������� 458
Serverless Providers����������������������������������������������������������������������������������������������������������� 458
Decompose Your Laravel Application����������������������������������������������������������������������������������� 459
Scaling Laravel with Serverless Auto-scaling and Event Triggers�������������������������������������������� 461
Serverless Auto-scaling������������������������������������������������������������������������������������������������������� 461
The Benefits of Serverless Auto-scaling for Laravel����������������������������������������������������������� 462
To Take Advantage of Serverless Auto-scaling�������������������������������������������������������������������� 462
Event Triggers and Background Jobs���������������������������������������������������������������������������������� 464
Load Testing and Performance Optimization����������������������������������������������������������������������� 467
Monitoring and Debugging Serverless Laravel Applications����������������������������������������������������� 469
Serverless Monitoring Tools������������������������������������������������������������������������������������������������ 469
Summary���������������������������������������������������������������������������������������������������������������������������������� 475

Chapter 19: Building Progressive Web Applications (PWAs) with Laravel����������� 477
Understanding Progressive Web Applications and Service Workers����������������������������������������� 478
Key Characteristics of Progressive Web Applications���������������������������������������������������������� 479
Service Workers������������������������������������������������������������������������������������������������������������������ 479
Converting Laravel Applications into PWAs������������������������������������������������������������������������������� 480
Set Up a Manifest File��������������������������������������������������������������������������������������������������������� 480
Offline Support and Caching Strategies for PWAs�������������������������������������������������������������������� 484
Offline Support�������������������������������������������������������������������������������������������������������������������� 485
Caching Strategies�������������������������������������������������������������������������������������������������������������� 486
Push Notifications and Background Sync in PWAs������������������������������������������������������������������� 488
Push Notifications��������������������������������������������������������������������������������������������������������������� 488
Background Sync���������������������������������������������������������������������������������������������������������������� 489
Optimizing PWAs for Performance and User Experience���������������������������������������������������������� 491
Performance Auditing���������������������������������������������������������������������������������������������������������� 491
Code Splitting���������������������������������������������������������������������������������������������������������������������� 491
Lazy Loading������������������������������������������������������������������������������������������������������������������������ 492

xix
Table of Contents

Responsive Design�������������������������������������������������������������������������������������������������������������� 492


Minify and Compress Assets����������������������������������������������������������������������������������������������� 492
Cache Control Headers�������������������������������������������������������������������������������������������������������� 493
Offline Page������������������������������������������������������������������������������������������������������������������������� 493
Optimize Images������������������������������������������������������������������������������������������������������������������ 494
Background Data Sync�������������������������������������������������������������������������������������������������������� 494
PWA-Specific Caching Strategies���������������������������������������������������������������������������������������� 494
Optimize Fonts��������������������������������������������������������������������������������������������������������������������� 495
Use Web Workers����������������������������������������������������������������������������������������������������������������� 495
Monitor Performance����������������������������������������������������������������������������������������������������������� 496
Summary���������������������������������������������������������������������������������������������������������������������������������� 496

Chapter 20: Advanced UI/UX Design Patterns for Laravel������������������������������������ 497


Designing User-Friendly Interfaces with Laravel’s Blade Templating Engine��������������������������� 498
Organizing Blade Templates������������������������������������������������������������������������������������������������ 499
Using Template Inheritance (Extends)��������������������������������������������������������������������������������� 499
Using Partials (Includes)������������������������������������������������������������������������������������������������������ 500
Blade Directives for Conditionals and Loops����������������������������������������������������������������������� 501
Blade Components (Laravel 7+)������������������������������������������������������������������������������������������ 501
Form Handling with Blade��������������������������������������������������������������������������������������������������� 502
Design Consistency������������������������������������������������������������������������������������������������������������� 502
Mobile-Friendly Design������������������������������������������������������������������������������������������������������� 502
Implementing Responsive Design and Mobile Optimization Techniques���������������������������������� 502
Use CSS Media Queries������������������������������������������������������������������������������������������������������� 503
Mobile-First Approach��������������������������������������������������������������������������������������������������������� 503
Use Responsive Frameworks���������������������������������������������������������������������������������������������� 504
Optimize Images������������������������������������������������������������������������������������������������������������������ 504
Touch-Friendly Interactions������������������������������������������������������������������������������������������������� 505
Accessibility Considerations������������������������������������������������������������������������������������������������ 505
Viewport Meta Tag��������������������������������������������������������������������������������������������������������������� 505
Performance Optimization��������������������������������������������������������������������������������������������������� 505
Test on Various Devices������������������������������������������������������������������������������������������������������� 506

xx
Table of Contents

Enhancing User Experience with CSS Animation and Transition Effects���������������������������������� 506
CSS Animations������������������������������������������������������������������������������������������������������������������� 506
CSS Transitions�������������������������������������������������������������������������������������������������������������������� 507
Keyframe Animations���������������������������������������������������������������������������������������������������������� 507
Delicate Hover Effects��������������������������������������������������������������������������������������������������������� 508
CSS Transitions for Smooth State Changes������������������������������������������������������������������������� 508
Animation Timing Functions������������������������������������������������������������������������������������������������ 509
Use Animations Sparingly���������������������������������������������������������������������������������������������������� 509
Designing Accessible Applications with Laravel����������������������������������������������������������������������� 509
Semantic HTML������������������������������������������������������������������������������������������������������������������� 510
ARIA Roles and Attributes���������������������������������������������������������������������������������������������������� 510
Focus Management������������������������������������������������������������������������������������������������������������� 511
Alternative Text for Images�������������������������������������������������������������������������������������������������� 511
Form Accessibility��������������������������������������������������������������������������������������������������������������� 511
Color Contrast���������������������������������������������������������������������������������������������������������������������� 511
Test with Assistive Technologies����������������������������������������������������������������������������������������� 512
Accessibility Auditing Tools������������������������������������������������������������������������������������������������� 512
Provide Transcripts and Captions���������������������������������������������������������������������������������������� 512
Implementing User Feedback and Usability Testing in Laravel Applications���������������������������� 512
Feedback Collection Mechanisms��������������������������������������������������������������������������������������� 512
Error Reporting�������������������������������������������������������������������������������������������������������������������� 513
Analyze User Behavior��������������������������������������������������������������������������������������������������������� 513
Usability Testing������������������������������������������������������������������������������������������������������������������ 514
User Surveys����������������������������������������������������������������������������������������������������������������������� 514
Feedback Analysis and Action Plan������������������������������������������������������������������������������������� 515
Iterative Improvement��������������������������������������������������������������������������������������������������������� 515
Accessibility Testing������������������������������������������������������������������������������������������������������������ 515
Performance Testing������������������������������������������������������������������������������������������������������������ 515
User Support and Communication��������������������������������������������������������������������������������������� 515
Bug Tracking and Issue Management��������������������������������������������������������������������������������� 515
Summary���������������������������������������������������������������������������������������������������������������������������������� 516

xxi
Table of Contents

Chapter 21: Advanced Analytics and Reporting in Laravel���������������������������������� 517


Integrating Analytics Tools with Laravel������������������������������������������������������������������������������������ 518
Let’s Explore How to Integrate Google Analytics with Laravel��������������������������������������������� 519
Collecting and Analyzing Application Metrics and User Behavior��������������������������������������������� 521
Logging�������������������������������������������������������������������������������������������������������������������������������� 521
Custom Event Listeners������������������������������������������������������������������������������������������������������� 522
Database Queries���������������������������������������������������������������������������������������������������������������� 522
User Tracking and Cookies�������������������������������������������������������������������������������������������������� 523
Third-Party APIs������������������������������������������������������������������������������������������������������������������� 523
Analyzing the Data��������������������������������������������������������������������������������������������������������������� 524
Improving User Experience�������������������������������������������������������������������������������������������������� 524
Building Custom Dashboards and Reports with Laravel����������������������������������������������������������� 524
Define Dashboard Requirements����������������������������������������������������������������������������������������� 525
Set Up a Laravel Project������������������������������������������������������������������������������������������������������ 525
Design the Database Schema��������������������������������������������������������������������������������������������� 526
Seed the Database with Sample Data��������������������������������������������������������������������������������� 527
Create Routes and Controllers��������������������������������������������������������������������������������������������� 528
Create Dashboard and Report Views����������������������������������������������������������������������������������� 529
Styling and Enhancements�������������������������������������������������������������������������������������������������� 530
Authentication and Authorization���������������������������������������������������������������������������������������� 530
Deploy the Dashboard��������������������������������������������������������������������������������������������������������� 530
Implementing A/B Testing and Conversion Tracking����������������������������������������������������������������� 530
Using Data Visualization Libraries with Laravel������������������������������������������������������������������������ 533
Summary���������������������������������������������������������������������������������������������������������������������������������� 536

Chapter 22: Advanced Third-Party Integrations��������������������������������������������������� 537


Integrating Laravel with Payment Gateways����������������������������������������������������������������������������� 538
Implementing Social Media and Authentication (OAuth) Integrations��������������������������������������� 543
Integrating Laravel with Email Marketing Services������������������������������������������������������������������ 545
Integrating Laravel with Cloud Storage Providers��������������������������������������������������������������������� 548
Building Custom API Integrations with Laravel������������������������������������������������������������������������� 550
Summary���������������������������������������������������������������������������������������������������������������������������������� 554
xxii
Table of Contents

Chapter 23: Securing Laravel Applications���������������������������������������������������������� 555


Implementing Two-Factor Authentication (2FA) in Laravel�������������������������������������������������������� 556
Here’s How 2FA Typically Works������������������������������������������������������������������������������������������ 557
To Enable 2FA in Laravel, You Can Follow These Steps������������������������������������������������������� 558
Securing User Input and Form Validation���������������������������������������������������������������������������������� 563
Use Laravel’s Validation Rules��������������������������������������������������������������������������������������������� 563
Preventing Cross-Site Scripting (XSS) and Cross-­Site Request Forgery (CSRF) Attacks���������� 566
Preventing Cross-Site Scripting (XSS) Attacks�������������������������������������������������������������������� 566
Preventing Cross-Site Request Forgery (CSRF) Attacks������������������������������������������������������ 567
Securing API Endpoints with API Keys and Rate Limiting��������������������������������������������������������� 568
Securing API Endpoints with API Keys��������������������������������������������������������������������������������� 568
Securing API Endpoints with Rate Limiting������������������������������������������������������������������������� 569
Implementing Content Security Policies (CSPs) and SSL/TLS Encryption�������������������������������� 571
The Main Goals of the Content Security Policy�������������������������������������������������������������������� 571
Implementing Content Security Policies (CSPs)������������������������������������������������������������������ 572
SSL/TLS Standard���������������������������������������������������������������������������������������������������������������� 573
Self-Signed Certificates������������������������������������������������������������������������������������������������������� 575
Summary���������������������������������������������������������������������������������������������������������������������������������� 577

Chapter 24: Advanced DevOps and Infrastructure Automation���������������������������� 579


Infrastructure as Code (IaC) with Laravel and Tools like Terraform������������������������������������������� 580
Here’s How Terraform Plan Acts as an Advisory������������������������������������������������������������������ 581
To Use Terraform with Laravel, You Would Typically������������������������������������������������������������ 582
To Perform a Destroy Operation (e.g., Removing Resources)���������������������������������������������� 583
Setting Up Terraform for Laravel����������������������������������������������������������������������������������������� 583
Steps to Set Up Terraform for Your Laravel IaC������������������������������������������������������������������� 583
Automating Deployment Pipelines with Laravel and CI/CD Tools���������������������������������������������� 587
Implementing Application Monitoring and Log Management��������������������������������������������������� 590
Application Monitoring�������������������������������������������������������������������������������������������������������� 592
Log Management����������������������������������������������������������������������������������������������������������������� 592

xxiii
Table of Contents

Continuous Performance Optimization and Auto-scaling��������������������������������������������������������� 594


Continuous Performance Optimization�������������������������������������������������������������������������������� 594
Auto-scaling������������������������������������������������������������������������������������������������������������������������ 595
Building Highly Available and Fault-Tolerant Laravel Infrastructures��������������������������������������� 596
Components of a Highly Available and Fault-Tolerant Laravel Infrastructure���������������������� 596
Web Application Layer��������������������������������������������������������������������������������������������������������� 599
Load Balancing�������������������������������������������������������������������������������������������������������������������� 600
Database Layer�������������������������������������������������������������������������������������������������������������������� 600
Caching�������������������������������������������������������������������������������������������������������������������������������� 601
File Storage������������������������������������������������������������������������������������������������������������������������� 601
Content Delivery������������������������������������������������������������������������������������������������������������������ 602
Monitoring and Logging������������������������������������������������������������������������������������������������������� 602
Security������������������������������������������������������������������������������������������������������������������������������� 602
Backup and Disaster Recovery�������������������������������������������������������������������������������������������� 603
Logging and Error Tracking�������������������������������������������������������������������������������������������������� 603
Summary���������������������������������������������������������������������������������������������������������������������������������� 604

Chapter 25: New Features and Updates in Laravel 10������������������������������������������ 605


The Central Role of PHP 8.1 in Laravel 10��������������������������������������������������������������������������������� 605
Readonly Properties������������������������������������������������������������������������������������������������������������������ 605
Array Is List������������������������������������������������������������������������������������������������������������������������������� 606
Enhancements to Laravel’s Official Packages�������������������������������������������������������������������������� 607
Improved Predis Version Compatibility������������������������������������������������������������������������������������� 609
Native Type Declarations����������������������������������������������������������������������������������������������������������� 609
Default Invokable Validation Rules�������������������������������������������������������������������������������������������� 611
Enhanced Database Operations with Native Column Modification Support����������������������������� 612
Native Retrieval of Column Types���������������������������������������������������������������������������������������������� 613
Enhanced Support for the whereExists() Method in the Eloquent Builder�������������������������������� 615
Optimizing Eager Loading��������������������������������������������������������������������������������������������������������� 616
$path Is Optional for Filesystem Methods�������������������������������������������������������������������������������� 617
Enhanced Database Expressions and Grammar-Specific Formatting��������������������������������������� 618

xxiv
Table of Contents

Enhanced SQL Server Query Performance with FETCH and OFFSET for Queries Without
orderBy������������������������������������������������������������������������������������������������������������������������������������� 620
Laravel Pennant������������������������������������������������������������������������������������������������������������������������ 621
Laravel Process Interaction������������������������������������������������������������������������������������������������������� 622
Pest Scaffolding������������������������������������������������������������������������������������������������������������������������ 624
Summary���������������������������������������������������������������������������������������������������������������������������������� 624

Index��������������������������������������������������������������������������������������������������������������������� 625

xxv
About the Author
Sivaraj Selvaraj’s work is focused on modern technologies
and industry best practices. His experience includes
frontend development approaches such as HTML5, CSS3,
and JavaScript frameworks, as well as creating responsive
web design to optimize user experience across devices. He
specializes in developing dynamic web applications with
server-side languages such as PHP, WordPress, and Laravel,
as well as managing and integrating databases with SQL and
MySQL. Sivaraj is enthusiastic about sharing his significant
expertise and experience, empowering readers to solve tough challenges and create
highly functional, visually appealing websites.

xxvii
About the Technical Reviewer
Yogesh Kamal Sharma is an application developer
enthusiast, consultant, and avid paperback reader. He is
presently associated with NICE Actimize to modernize
AML programs by bringing together machine learning and
domain expertise to combat money laundering and terrorist
financing. He graduated from VSIT Mumbai, is a father of
one, and enjoys his free time golfing.

xxix
Acknowledgments
I am indebted to my mentors and fellow developers in the Laravel community. Your
guidance, insights, and shared knowledge have been pivotal in my growth as a Laravel
developer. The open collaboration and spirit of learning in the community have inspired
me to strive for continuous improvement.
I extend my gratitude to the reviewers and editors who diligently reviewed and
refined the content, ensuring its accuracy and clarity.
To my friend Divya Modi, thank you for your unwavering camaraderie and
encouragement throughout this journey. Your insights and discussions have enriched
my understanding of book development as a whole.
To all the readers and supporters of this book, thank you for your interest in learning
and mastering Laravel. Your passion for growth and dedication to honing your skills
motivate me to share my knowledge and experiences.
This book would not have been possible without the contributions of each individual
mentioned here. Your belief in this project and your unwavering support have been
integral to its success.
With sincere appreciation

xxxi
Introduction
Welcome to Building Real-Time Marvels with Laravel: Create Dynamic and Interactive
Web Applications. This book will introduce you to the exciting world of Laravel, a
powerful PHP framework that allows developers to create cutting-edge web apps with
real-time functionality. Whether you’re a seasoned developer or just starting out, this
thorough tutorial will provide you with the knowledge and skills you need to create
remarkable and engaging web experiences with Laravel.
Because of its elegance, simplicity, and feature-rich environment, Laravel has
garnered enormous appeal in the online development community. It gives developers a
strong collection of tools and conventions that help streamline the development process,
letting them focus on creating novel features and great user experiences.
We will cover the Laravel framework in a logical and organized manner, chapter by
chapter, throughout this book. Each chapter delves further into the Laravel environment,
covering fundamental principles, advanced techniques, and best practices to help you
become an expert Laravel developer.
Our goal is to provide you with the knowledge and confidence you need to create
real-time miracles—online applications that engage users with dynamic information,
interactive interfaces, and seamless communication. This book will walk you through
the process of creating a real-time chat application, a collaborative dashboard that
displays real-time data, or any other interactive online application.
If you’re new to Laravel, don’t worry! We’ll start with an overview of the Laravel
ecosystem, covering its key principles, architecture, and vital components. You will learn
how to configure your development environment so that you have everything you need
to begin developing Laravel applications.
Fear not, those who are already familiar with Laravel! There are numerous advanced
topics available to challenge and extend your knowledge. This book covers a wide
range of subjects, from learning complicated routing strategies to fine-tuning database
interactions with Eloquent Object-Relational Mapping (ORM) to adding real-time
features with WebSockets to improving performance and scaling your applications.
Throughout the journey, you will experience practical examples, real-world use
cases, and hands-on exercises to help you understand the ideas covered. Each chapter

xxxiii
Another random document with
no related content on Scribd:
Natural History of aquatic Insects, 1895, p. 376.

[88]

Tr. Amer. ent. Soc. xv. 1888, p. 18.

[89]

Op. cit. v. 1881, p. 91; cf. Sharp, Tr. ent. Soc. London, 1882, p. 61.

[90]

P. ent. Soc. Washington, ii. 1892, p. 341.

[91]

Descent of Man, i. 1890, p. 338; The views of Landois and Recker,


Arch. f. Naturgesch. lvii. 1, 1891, p. 101, are erroneous.

[92]

See J. Linn. Soc. Zool. xiii. 1876, p. 161.

[93]

For many particulars as to respiration of Dytiscus, and peculiarities


of the larva see Miall, Aquatic Insects, 1895, pp. 39, etc. (In the
figure given on p. 60 the large stigma on the terminal segment of
the abdomen is omitted, though it is referred to in the text.)

[94]

For classification and structure see Sharp, "On Dytiscidae," Sci.


Trans. R. Dublin Soc. (2) ii. 1882.

[95]

Descriptions of larvae that may possibly be those of Paussids


have been published by Xambeu, Ann. Soc. Linn. Lyon, xxxix.
1892, p. 137, and Erichson, Arch. Naturgesch. xiii. 1847, p. 275.

[96]
Arch. Mus. Paris (2), viii. and ix. 1887.

[97]

For classification and monograph of the family, see Régimbart,


Ann. Soc. ent. France, 1882, 1883, and 1886. For a catalogue,
Séverin, Ann. Soc. ent. Belgique, xxxiii. 1889.

[98]

Ann. Soc. ent. France, xxi. 1852, p. 619.

[99]

Horn, Tr. Amer. ent. Soc. xv. 1888, p. 23; Riley, Insect Life, i. 1889,
p. 300.

[100]

Insect Life, i. 1889, pp. 200 and 306.

[101]

Tr. Amer. ent. Soc. viii. 1880, pp. 219-321.

[102]

Westwood, Tr. ent. Soc. London (N.S.) iii. 1855, p. 90; Wasmann,
Krit. Verzeichniss Myrmekoph. Arthropod. 1894, p. 121.

[103]

Rev. ent. franc. ix. 1890.

[104]

Die Käfer von Mitteleuropa: II. Familienreihe, Staphylinoidea.


Vienna, 1895 and 1899.

[105]

Vergleichende Studien über Ameisengäste, Nijhoff, 1890; and


Tijdschr. ent. xxxiii. 1890, pp. 93, etc.; Biol. Centralbl. xv. 1895, p.
632.

[106]

Schiödte, Ann. Sci. Nat. Zool. (4) v. 1857, p. 169.

[107]

Biol. Centr. Amer. Col. ii. pt. i. 1888, p. 156.

[108]

Monograph, Trichopterygia illustrata, by A. Matthews, London,


1872.

[109]

For further information refer to Matthews, An Essay on


Hydroscapha, London, 1876, 20 pp. 1 pl.

[110]

Ann. Nat. Hist. (5) xix. 1887, p. 115.

[111]

Larves de Coléoptères, 1878, p. 11, pl. i.

[112]

Biol. Centr. Amer. Col. ii. pt. i. p. 438.

[113]

The family was monographed by the Abbé de Marseul in Ann.


Soc. ent. France, 1853-1862, but great additions have been made
since then.

[114]

For characters of larvae of various genera, see Perris, Larves, etc.


p. 24.
[115]

SB. Ak. Wien. xxiv. 1857, p. 330.

[116]

Catalogue of Trogositidae, by Leveillé, in Ann. Soc. ent. France,


1888, p. 429.

[117]

For classification, see Sharp, Biol. Centr. Amer. Col. ii. pt. i. 1894,
p. 443.

[118]

See Ganglbauer, Käf. Mitteleuropas, i. p. 530, as well as Leconte


and Horn Classification, etc., p. 130.

[119]

Perris, Larves, etc., p. 75.

[120]

Ritsema, Catalogue of Helota, Notes Leyden Mus. xiii. 1891, p.


223, and xv. 1893, p. 160.

[121]

Zool. Anz. xviii. 1895, p. 244.

[122]

Gerstaecker, Monographie der Endomychiden, Leipzig, 858, 1433


pp. Since this work was published, the species known have been
multiplied two or three times.

[123]

Stettin. ent. Zeit. xlii. 1881, pp. 104-112.

[124]
It is probable that we do not know more than the fiftieth part of the
existing species, most of which lead lives that render them very
difficult to find.

[125]

Bull. ent. ital. 1886, p. 406, and Ent. Zeit. Stettin, xliii. 1887, pp.
201-206. Emery does not mention the name of the species, but we
presume it to be the common Italian fire-fly, Luciola italica.

[126]

Zeitschr. wiss. Zool. xxxvii. 1882, p. 354; also Emery, op. cit. xl.
1884, p. 338. For another theory as to the luminescence, see
p. 259.

[127]

Bull. Soc. Zool. France, xii. 1887, p. 137, postea.

[128]

Deutsche ent. Zeitschr. xxxii. 1888, pp. 145-167.

[129]

Ent. Mag. xxiv. 1887, p. 148.

[130]

Larves des Coléoptères, 1878, p. 208.

[131]

Ann. Soc. ent. France, 1894, p. 7.

[132]

Perris, Ann. Soc. ent. France (2) ix. 1851, p. 48.

[133]

Arch. Naturgesch. xlviii. 1, 1882, p. 371.


[134]

"Les Élatérides lumineux," Bull. Soc. Zool. France, xi. 1886; also
Leçons de Physiologie générale, Paris, 1898, and C.R. Ac. Sci.
cxxiii. 1896, p. 653.

[135]

It seems impossible to understand the morphology of the anterior


segments by mere inspection; the anterior spiracle being seated
on the segment behind the broad thorax. Considerable difference
of opinion has prevailed as to what is head, what thorax; the aid of
embryology is necessary to settle the point. The larva described by
Westwood (Mod. Classif. i. 1839, p. 229), and figured as probably
Buprestis attenuata is doubtless a Passalid.

[136]

Casey has examined the wings in the genus Blapstinus (an


"apterous" genus), and found that the wings are extremely varied
in development, according to the species; in no case, however, did
they appear to be capable of giving more than a laboured and
feeble flight.—Ann. New York Ac. v. 1890, p. 416.

In Eleodes, though the meso- and meta-notum are formed of


delicate membrane, the wings exist as minute flaps, requiring
some examination for their detection.

[137]

Ann. Nat. Hist. (4) vi. 1870, p. 314; and Ent. Mag. xxvii. 1891, p.
18.

[138]

Mitt. Schweiz. ent. Ges. iv. 1876, p. 556.

[139]

Ann. Soc. ent. France, lx. 1891, p. 447.


[140]

"On the Natural History, Anatomy, and Development of the Oil-


Beetle, Meloe," Tr. Linn. Soc. xx. 1851, p. 297; and xxi. 1853, p.
167.

[141]

Rep. U.S. ent. Commission, i. 1878, p. 297.

[142]

Amer. Nat. xvii. 1883, p. 790.

[143]

For illustration of this metamorphosis, see Vol. V. p. 159 of this


work.

[144]

Les Insectes Vésicants, Paris 1890, 554 pp. Parts of this work
were previously published in J. de l'Anat. Phys., xxi. xxii. xxiii. 1886
and 1887.

[145]

Genera des Coléoptères (Suites à Buffon), x. Paris, 1874, p. 15.

[146]

Berlin. ent. Zeit. 1887, p. 325, and 1889, p. 299.

[147]

Ann. Soc. Liége, x. 1855, p. 260.

[148]

Mem. Soc. Liége, xvi. 1861, p. 387.

[149]

Packard, 5th Rep. U.S. Ent. Comm. 1890, p. 689.


[150]

Not a growing tree, but the instrument used for stretching boots.

[151]

Berlin. ent. Zeitschr. xli. 1896, SB. p. 22.

[152]

Sharp, Ann. Soc. ent. Belgique, xxviii. 1884, CR. p. cvii.

[153]

For a more extensive account of Rhynchites betulae and others


refer to Wasmann. Der Trichterwickler, Münster, 1884, and Debey,
Beiträge zur Lebensund Entwickelungsgeschichte ... der
Attelabiden, Bonn, 1846. The first includes an extensive
philosophical discussion; the second is a valuable collection of
observations.

[154]

Bull. U.S. Dep. Agric. ent. New series, No. 7, 1897.

[155]

Perris, Ann. Sci. Nat. (2) xiv. 1840, p. 89, pl. iii.

[156]

In the males of the genus Cedeocera the tips of the elytra are
drawn out into processes almost as long as the elytra themselves,
and rivalling the forceps of earwigs.

[157]

The stature of the individuals of the same species is, in some of


these Brenthidae, subject to extreme variation, especially in the
males, some individuals of which—in the case of Brenthus
anchorago—are five times as long as others.
[158]

This remark applies to the Strepsiptera parasitic on Hymenoptera:


nothing whatever is known as to the life-histories of the species
that attack Hemiptera.

[159]

Although not an invariable, it seems that it is a general rule that the


Stylops produced from the body of one individual are all of one
sex; it has even been stated that female bees produce more
especially female Stylops, and male bees male Stylops. If any
correlation as to this latter point exist, it is far from general.

[160]

Von Siebold, Arch. Naturges. ix. 1843, pp. 137-161. Nassonoff's


recent paper is in Russian, but so far as we can gather (cf. Zool.
Centralbl. i. 1894, p. 766), it does not add greatly to the data
furnished by von Siebold.

[161]

Ent. Meddel. v. 1896. p. 148, and Ov. Danske Selsk. 1896, p. 67.

[162]

Horae Soc. ent. Ross. xiv. 1879, p. 14.

[163]

Named by Mr. Distant Callidea baro; according to the Brussels


catalogue of Hemiptera, Chrysocoris grandis var. baro.

[164]

Kellogg, Kansas Quarterly, ii. 1893, p. 51, plate II.

[165]

Jena. Zeitschr. Naturw. xviii. 1885, p. 751.


[166]

The writer is not quite convinced that the supposed mandibles of


these Macrolepidoptera are really entitled to be considered as
such.

[167]

Tr. ent. Soc. London, 1893, p. 263.

[168]

Amer. Natural. xxix. 1895, p. 637. It should be recollected that


many Lepidoptera do not possess any proboscis.

[169]

Jena. Zeitschr. Naturw. xviii. 1885, p. 168.

[170]

Amer. Natural. xiv. 1880, p. 313.

[171]

For an account of the structures at the tip of the proboscis of this


moth, and of the beautiful manner in which the lobes of the
maxillae are dovetailed together, see Francis Darwin, Quart. J.
Micr. Sci. xv. 1875, p. 385. For details as to numerous
proboscides, and as to the difficulties that exist in comprehending
the exact mode of action of the organ, refer to Breitenbach's
papers, especially Jena. Zeitschr. Naturw. xv. 1882, p. 151.

[172]

See Cholodkovsky, Zool. Anz. ix. p. 615; Haase, t.c. p. 711; also
Riley, P. ent. Soc. Washington, ii. 1892, p. 310.

[173]

Fourth Rep. U.S. Entom. Commission, 1885, p. 49.


[174]

C.R. Ac. Sci. Paris, cxviii. 1894, p. 360; and his Thesis, Bordeaux,
1895.

[175]

C.R. Ac. Sci. Paris, cxviii. 1894, p. 542.

[176]

Fauna of British India, Moths, i. 1892, p. 6.

[177]

It is impossible for us to treat of the difficulties that exist on this


point, and we must refer the student to the pamphlet, "The
Venation of the Wings of Insects," by Prof. Comstock, Ithaca,
1895, being a reprint, with an important prefatory note, from the
Elements of Insect Anatomy, by J. H. Comstock and V. L. Kellogg,
also to Packard's discussion of the subject in Mem. Ac. Sci.
Washington, vii. 1895, pp. 84-86. The method of Spuler, alluded to
in these two memoirs, is based on development, and, when
extended, will doubtless have very valuable results. See Spuler,
Zeitschr. wiss. Zool. liii. 1892, p. 597.

[178]

The structure and development of scales and nervures is dealt


with as part of the brief study of the development of the wing, on p.
329, etc.

[179]

The internal anatomy of Lepidoptera has not been extensively


studied. For information refer to Dufour, C.R. Ac. Paris, xxxiv.
1852, p. 748; Scudder, Butt. New England, i. 1889, p. 47; Minot
and Burgess, Fourth Rep. U. S. Entom. Comm. 1885, p. 53.

[180]

Tr. Linn. Soc. London (2), v. 1890, p. 143.


[181]

P. ent. Soc. Washington, ii. 1892, p. 305.

[182]

Acta Ac. German. li. 1887, p. 238.

[183]

Ann. Soc. ent. France, 1887, pp. 384-404, Pl. 7.

[184]

Isis, 1845, p. 835.

[185]

For anatomy of caterpillars refer to Lyonnet's famous work, Traité


anatomique de la chenille qui ronge le bois de saule, La Haye,
1762.

[186]

See Plateau, Bull. Ac. Belgique, xv. 1888, p. 28; in reference to


structure of ocelli, Blanc, Tête du Bombyx mori ... 1891, pp. 163,
etc.; and Landois in Zeitschr. wiss. Zool. xvi. 1866, p. 27.

[187]

Entwickelungsgeschichte der Schmetterlinge, Cassel, 1815.

[188]

Tr. Linn. Soc. London, Zool. 2nd Ser., v. 1890, pp. 147, 148.

[189]

For information as to the structure and function of the silk-vessels,


refer to Helm, Zeitschr. wiss. Zool. xxvi. 1876, p. 434; and Gilson,
La Cellule, vi. 1890, p. 116.

[190]
Jahresber. Schlesisch. Ges. lviii. 1881, p. 116.

[191]

The student will find important information as to the varieties of


external form of pupae in Dr. T. A. Chapman's writings; see
especially Tr. ent. Soc. London, 1893, 1894, and 1896.

[192]

Latter, Tr. ent. Soc. London, 1895, p. 399.

[193]

Bull. Soc. Vaudoise, xxx. 1894, No. 115.

[194]

Zeitschr. wiss. Zool. liii. 1892, p. 623.

[195]

Zool. Jahrb. Anat. iii. 1889, p. 646.

[196]

Amer. Natural., xxvii. 1893, p. 1018.

[197]

Amer. Natural., xxxii. 1898, p. 256.

[198]

Zeitschr. wiss. Zool. viii. 1857, p. 326.

[199]

Phil. Trans. 186 B, 1896, No. 15.

[200]

Natural Science, viii. 1896, p. 94.


[201]

Bull. Soc. ent. France, 1896, p. 257.

[202]

Ent. Record, vi. 1895, p. 258.

[203]

Trans. ent. Soc. London, 1892, p. 293, etc.

[204]

The term mimicry is sometimes used in a wider sense; but we


think it better to limit it to its original meaning. The word is a most
unfortunate one, being both inadequate and inaccurate.

[205]

Trans. Linn. Soc. xxiii. 1862, p. 507.

[206]

A summary of the chief aspects of the question is contained in


Beddard's Animal Coloration, London, 1892. An account of the
subject with numerous illustrations has been given by Haase,
"Untersuchungen über die Mimicry," Bibl. Zool. iii. 1893, Heft viii.
Those who wish to see the case as stated by an advocate may
refer to Professor Poulton's work, The Colours of Animals
(International Scientific Series), lxviii. London, 1890.

[207]

P. Zool. Soc. London, 1883, p. 372.

[208]

Kosmos, xix. 1886, p. 353. The Insects alluded to by both these


naturalists are now, we believe, placed in the Family Syntomidae
(see p. 388).
[209]

Stett. ent. Zeit. li. 1891, p. 264; and lvi. 1895, p. 234.

[210]

For an account of the antennae of butterflies, see Jordan, Nov.


Zool. v. 1898, pp. 374-415.

[211]

Haase first proposed the name Netrocera (Deutsche ent. Zeit. Lep.
iv. 1891, p. 1) for Hesperiidae, as a division distinct from all other
butterflies; Karsch replaced the name in the following year by
Grypocera, because Netrocera is the name of a genus.

[212]

The literature of butterflies has become extremely extensive. The


following works contain information as to general questions: 1,
Scudder's Butterflies of New England, a beautifully illustrated work
completed in 1889, and replete with interesting discussions. 2,
Staudinger, Schatz and Röber, Exotische Tagfalter, in three folio
volumes (Fürth, 1884-1887), with illustrations of exotic butterflies
and a detailed sketch of their characters. 3, Enzio Reuter, "Uber
die Palpen der Rhopaloceren," in Acta Soc. Sci. Fenn. xxii. 1896,
treating fully of classification and phylogeny.

[213]

Journal of Entomology, i. 1862, p. 218: for early instars of South


American Nymphalidae see Müller, Zool. Jahrb. Syst. i. 1886, p.
417.

[214]

This is the subject of Scudder's Life of a Butterfly, 1893.

[215]

P. Zool. Soc. London, 1883, p. 205.


[216]

Finn, J. Asiat. Soc. Bengal, lxvi. 1896, p. 528; lxvii. 1897, p. 213.

[217]

Trans. Linn. Soc. xxiii, 1862, p. 495.

[218]

Kosmos, xix. 1886, p. 355.

[219]

P. ent. Soc. London, 1879, p. xxix.

[220]

Allen's Naturalists' Library, Butterflies, i. 1896.

[221]

A most unfortunate diversity exists in the generic names applied to


these Vanessa, as well as in those of many other Lepidoptera.

[222]

Ann. Nat. Hist. (6), iv. 1889, p. 212.

[223]

P. Zool. Soc. London, 1892, p. 191.

[224]

Bull. Soc. ent. France, 1856, pp. c, ci.

[225]

Baker, Tr. ent. Soc. London, 1887, p. 175, Pl. ix.

[226]

Ann. Soc. ent. France (4), vii. 1867, p. 665, Pl. xiii.
[227]

J. Bombay Soc. ix. 1895, pp. 338-341.

[228]

Hopkins, Phil. Trans. 186 B, 1895, p. 661.

[229]

Ann. Nat. Hist. (6), iv. 1889, p. 213. We trust there will not be many
more Künstlers, as this beautiful butterfly must certainly become
extinct, if the female be really as rare as is supposed.

[230]

Mem. Ac. Washington, vii. 1895, p. 57.

[231]

Tr. ent. Soc. London, 1893, p. 97, with Suppl. op. cit. 1896, pp. 129
and 567.

[232]

Amer. Natural. xxix. 1895, p. 1066. See also Ann. N. York Ac. viii.
1895, p. 194, and Ent. Record, 1897, pp. 136 and 196.

[233]

Handbook of British Lepidoptera, 1895.

[234]

London, 1892. Published under the authority of the Secretary of


State for India in Council.

[235]

Those numbered 2, 8, 10, 17, 22, 27, 44, and 46 in our


arrangement.

[236]
For explanatory diagram of the wings, see Fig. 161, I. When the
nervuration is obscured by the wing-scales, it may be rendered
temporarily visible by the application, with a camel's-hair brush, of
a little benzine. The wings may be permanently denuded of their
scales by being placed for a short time in Eau de Javelle
(hypochlorite of potash).

[237]

The genus Cyphanta (one species from India) has nervule 5 of the
fore wing proceeding from the lower angle of the cell.

[238]

This is a mistake of Sir George Hampson's. It has long been


known that the female of Heterogynis does not leave the cocoon
(for references see p. 392); the larvae, however, do not live in
cases, as those of Psychidae do.

[239]

See Westwood, Tr. Linn. Soc. London (2), i. 1877, p. 165, etc.

[240]

For habits of some Brazilian Castnia see Seitz, Ent. Zeit. Stettin, li.
1890, p. 258.

[241]

For pupa see Chapman, Ent. Rec. vi. 1895, pp. 286, 288.

[242]

Souvenirs entomologiques, quatrième série, 1891, pp. 39-46.

[243]

Amer. Natural. xii. 1878, p. 379.

[244]
Cotes, "Wild Silk Insects of India," Ind. Mus. Notes, ii. No. 2, 1891,
15 plates.

[245]

See on this subject Pérez, Act. Soc. Bordeaux, xlvii. 1894, p. 236,
etc.

[246]

Berlin. ent. Zeitschr. xxvii. 1883, p. 9.

[247]

Tr. Linn. Soc. ser. 2, ii. 1885, p. 421.

[248]

Psyche, vi. 1893, p. 385.

[249]

Bar and Laboulbène, Ann. Soc. ent. France, (v.) iii. 1873, p. 300.

[250]

Op cit. (5), vii. 1877, p. 181; and Ent. Zeit. Stettin, xxxix. 1878, p.
221; and xliv. 1883, p. 402.

[251]

Ann. New York Ac. viii. 1893, p. 48.

[252]

Tr. ent. Soc. London, n.s. iii. 1854, p. 1.

[253]

Dyar says, "We may surmise that it is to present a terrifying


appearance toward small enemies." He calls the Insect both
Perophora and Cicinnus, melsheimeri, and states that it belongs
[according to the larva] to Tineidae; the appendages he considers
to be enormously developed setae. J. N. York ent. Soc. iv. 1896, p.
92.

[254]

Tijdsch. Ent. xxxviii. 1895, p. 56, Pl. 4.

[255]

Ann. New York Ac. viii. 1893, p. 48.

[256]

Weyenbergh, Tijdschr. Ent. xvii. 1874, p. 220, Pl. xiii.

[257]

Jones, P. Liverpool Soc. xxxiii. 1879, p. lxxvii.

[258]

Studies in the Theory of Descent, part 2, London, 1881.

[259]

Tr. ent. Soc. London, 1885 and 1886.

[260]

Tijdschr. Ent. xl. 1897, pp. 27-103, 4 plates.

[261]

Tr. ent. Soc. London, 1884, p. 351.

[262]

Tr. ent. Soc. London, 1887, p. 297, Pl. x.

[263]

See Poulton, Tr. ent. Soc. London, 1886, etc.

Вам также может понравиться