Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bearcodi/laravel-injecting-middleware-testing-example
An example Laravel application dealing with resolving and injecting application container dependencies into middleware and working with TDD
https://github.com/bearcodi/laravel-injecting-middleware-testing-example
Last synced: about 11 hours ago
JSON representation
An example Laravel application dealing with resolving and injecting application container dependencies into middleware and working with TDD
- Host: GitHub
- URL: https://github.com/bearcodi/laravel-injecting-middleware-testing-example
- Owner: bearcodi
- Created: 2019-08-25T21:09:03.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T08:14:21.000Z (almost 2 years ago)
- Last Synced: 2023-08-03T09:07:05.526Z (over 1 year ago)
- Language: PHP
- Size: 899 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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](https://laracasts.com/discuss/channels/testing/app-singleton-and-no-session), feel free to use it as a jumping point for something magical!!!
## Classes that make this happen
Class | Purpose
:- | :-
[`App\CustomState`](app/CustomState.php) | A simple object that adds checks on the authenticated user.
[`App\Http\Middleware\UserOnboarding`](app/Http/Middleware/UserOnboarding.php) | Our custom middleware that uses the `CustomState` class to check that a user needs onboarding.
[`App\Providers\AppServiceProvider`](app/Providers/AppServiceProvider.php) | Where we register our singleton instance of `CustomState`
[`App\Http\Kernel`](app/Http/Kernel.php) | Where we register our custom middleware.