Skip to main content

Posts

Showing posts from January, 2021

Laravel: The hidden SetCacheHeaders Middleware

There are a lot of useful middlewares already registered inside Laravel, like the   authentication mechanisms ,   authorization , a   throttler , and even the one responsible to make   route model binding   possible. Practically, your middleware needs are covered. Except for one. There is one middleware that doesn’t get the spotlight in Laravel. It’s called   SetCacheHeaders , which is aliased as   cache.headers . And, there is no mention of it in the documentation. I’m not joking, guys: Who, when, how? A quick look around in the   api documentation   and the   source repository   says this middleware was added   added before christmas of 2017   after   a lengthy discussion , but it's a mystery why nobody has talked about it since it’s seems very…   convenient . In any case, after making this article, my   PR to the documentation   was accepted, so   you should find it now in the documentation . A ...

Configuring Auth Guards For Multiple Users in Laravel

  I’m relatively new to using Laravel 5. Up until recently I managed a few applications that were Laravel 3 and 4.2, sadly we never had the time to migrate them. When I started a new project I chose Laravel 5 (5.5 was the latest ver s ion as of starting this article, but has been updated for 5.6) and one of the best features was the ability to use multiple auth guards. This is great for applications that have 2 sets of users (e.g. customers, staff) and so needed their own login pages etc. In this article we’re going to go over setting them up and what other things need to be considered. Install Laravel First thing we need to do is create a Laravel app (You can skip this part if you already have one). composer create-project --prefer-dist laravel/laravel auth_app Update .env file Now you should update your .env folder to fit your needs. i.e setting a database to use. For this article the database is probably the only thing you’ll need to change. I’ve also setup the domain to be ...