Is This Considered To Be A Custom Facade Approach In Laravel?
I have piece of functionality that identifies access by a given token (string). If a valid token is given the session should be populated with a valid entry (using the
SessionInterface). I've set up my
VerifyToken middleware and would like to use a Guard-like approach for my token validation and session storage.
My question, is this type of functionality considered to be a facade in Laravel? If so; what would be the appropiate location to store these files (e.g.
app\Facades and also a
app\Facades\Contracts to store the interfaces)?
A Facade in Laravel is only a way to resolve a binding from the service container.
So, to me, Facades aren't considered as 'application functionality' themselves, but instead as a way to access services (that provide functionality) stored in your Service Container
That being said, if you want to build services with a Guard-like approach, i think that, as usual, the directory structure is up to you: Laravel is very flexible in this context
Once you have built your service classes, if you think that it would be useful, you could implement one or more Facades to access some of the services.
Personally i'm not a big Facade fan, i think it's better to use Dependency Injection ( via method or constructor parameters ) where possible: this will inject your services where needed, but in the same time keeping your code-dependencies more clear, as they are immedialty visible from the method's signature
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?