Welcome Guest, Not a member yet? Register   Sign In
Avoid using CI4 filters
#1

I think this is one of the very poorly implimented features in CI4.

01. It's doesn't support for multiple filters for single route.

02. There is no support for chained filters like in the form validation. For this reason we have to do authentication like stuff in every filters and its get repeated in every filter.

03. There is no better way to know which route we are currently on in the filters. We have to do lots of if() block just to verify routes.

So I suggest you to use old school type methods. like,

Do stuff top of the controller method or end of the controller method. I know it's looks bad but it's much more simpler and well scale.

Thanks.
Reply
#2

You can combine multiple filters into one alias, making complex sets of filters simple to apply:

PHP Code:
public $aliases = [
    'apiPrep' => [
        \App\Filters\Negotiate::class,
        \App\Filters\ApiAuth::class,
    ]
]; 
https://codeigniter4.github.io/CodeIgnit...ml#aliases
Reply
#3

(02-28-2021, 07:38 PM)kenjis Wrote: You can combine multiple filters into one alias, making complex sets of filters simple to apply:

PHP Code:
public $aliases = [
    'apiPrep' => [
        \App\Filters\Negotiate::class,
        \App\Filters\ApiAuth::class,
    ]
]; 
https://codeigniter4.github.io/CodeIgnit...ml#aliases

But passing filter specific params for multiple filters is still a nightmare.
Reply
#4

Oh, I see.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB