This video requires a TekCasts subscription.

Available to all subscribers with an active plan.

Jan 29, 2026
17m:2s

Custom Middleware

Classification
Software Engineering | Frameworks | Laravel
Keywords
laravel | php

About This Episode:

In this video, we explore how to create and use custom middleware in Laravel—one of the most powerful tools for intercepting and transforming HTTP requests and responses.

You'll learn how middleware works behind the scenes, how to build your own, and how to apply it to your routes using both class names and aliases. We walk through several practical examples that demonstrate how middleware can redirect users, modify incoming request data, and even alter outgoing HTML responses.

What We Cover
- Generating custom middleware with Artisan
- Understanding the handle() method lifecycle
- Adding logic before and after the request reaches your controller
- Building a middleware that performs redirects
- Creating route aliases for cleaner middleware usage
- Modifying incoming request data (e.g., normalizing phone numbers)
- Injecting additional content into outgoing HTML responses
- Managing configuration-driven UI banners
- Tagging and pushing source code for versioning

This video provides a solid foundation for writing expressive, maintainable middleware tailored to your application's needs.

💥 About the Series:
Pragmatic Laravel focuses on building real applications with Laravel — emphasizing clarity, maintainability, and thoughtful design decisions instead of shortcuts or magic.

#Laravel #PHP #WebDevelopment #SoftwareEngineering #Coding #Developers #Programming #FullStack #TekCasts
Bob Cravens

Bob Cravens

Owner
TekFoundry
Wisconsin
United States
Short Bio:
Bob Cravens is a seasoned technology leader, software architect, and educator with a passion for empowering others through practical, real-world knowledge. As the founder of TekFoundry, Bob has dedicated his career to designing and delivering innovative software solutions that combine cutting-edge technology with elegant simplicity.

At TekCasts, Bob leverages over two decades of experience in software engineering, application architecture, and team leadership to create engaging, high-impact courses for developers and technology professionals. His instructional style is rooted in practical application, offering insights drawn from his extensive background in industries like medical devices and global technology consulting.

Bob’s expertise spans a variety of technologies and methodologies, including PHP/Laravel, FastAPI, and DevOps, as well as architecture best practices and team dynamics. Whether teaching foundational concepts or advanced strategies, he’s passionate about helping others turn complex challenges into streamlined solutions.

When not crafting elegant code or inspiring the next generation of tech innovators, Bob enjoys exploring the intersection of technology, business strategy, and creative problem-solving.