CodeIgniter Forums
Order of filter - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Order of filter (/showthread.php?tid=86038)



Order of filter - motoroller - 01-03-2023

I have 2 filters one is global and another one in routers for few controllers

and i saw when i load controllers with extra filter
like
$routes->get('/', [StockShop::class, 'Index/List'], [ 'filter' => 'isBlocked' ]);

firstly execute isBlocked filter than global one, is it possible change order?
Rightly execute global first than others


RE: Order of filter - InsiteFX - 01-04-2023

The filters are executed in the order defined in the config file. However, if enabled, DebugToolbar is always executed
last because it should be able to capture everything that happens in the other filters.


RE: Order of filter - motoroller - 01-04-2023

(01-04-2023, 12:06 AM)InsiteFX Wrote: The filters are executed in the order defined in the config file. However, if enabled, DebugToolbar is always executed
last because it should be able to capture everything that happens in the other filters.

In config only global,
in routers setting filter in route, how config order?


RE: Order of filter - kenjis - 01-04-2023

(01-03-2023, 11:30 PM)motoroller Wrote: firstly execute isBlocked filter than global one, is it possible change order?

No, unless you extend/replace the framework class.


RE: Order of filter - kenjis - 09-23-2023

I sent a PR to change the order.
https://github.com/codeigniter4/CodeIgniter4/pull/7955