You should put this code in a file in config/bootstrap directory of your app, then load it in config/bootstrap.php by requiring it (just like other bootstrap files). It will load those filters during Lithium bootsrap