Question

I know I can do this:

$f3->set('ONERROR',function($f3){
  echo \Template::instance()->render('error.html');
});

I want to work in routes.ini, is it possible to define it there?

; Process login form submission
GET|POST /login="Controllers\Main->login"
; Logout
GET /logout="Controllers\Main->logout"

;Errors
ONERROR="Controllers\Main->error"
Was it helpful?

Solution

It can't be defined as a route but it can be defined in the same file. Since your "routes.ini" is simply a config file which is loaded by F3's config(), you can do something like

[routes]
; Process login form submission
GET|POST /login="Controllers\Main->login"
; Logout
GET /logout="Controllers\Main->logout"

[globals]
;Errors
ONERROR="Controllers\Main->error"

You can read more about it here: https://github.com/bcosca/fatfree#configuration-files

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top