• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
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


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.