/laravel-injecting-middleware-testing-example

An example Laravel application dealing with resolving and injecting application container dependencies into middleware and working with TDD

Primary LanguagePHP

Laravel Example application playing with custom middleware and app containers in testing

This was done using Laravel 5.8 but is easily portable to newer versions.

This is an exercise to scratch an itch and to respond to a Laracasts thread, feel free to use it as a jumping point for something magical!!!

Classes that make this happen

Class Purpose
App\CustomState A simple object that adds checks on the authenticated user.
App\Http\Middleware\UserOnboarding Our custom middleware that uses the CustomState class to check that a user needs onboarding.
App\Providers\AppServiceProvider Where we register our singleton instance of CustomState
App\Http\Kernel Where we register our custom middleware.