Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass arguments in a route when defined in ini files in fatfree framework?

In fatfree framework, I am defining the routes in ini files. like:

GET|POST /admin/login = controllers\siteadmin\Login->index
GET|POST /admin/login/@action = controllers\siteadmin\Login->@action

Now I was wondering how to pass arguments to the functions in this setup. Also how do I set cache and ttl values for each route?

like image 269
Aoi Avatar asked Sep 19 '25 13:09

Aoi


1 Answers

In your .ini file, you can pass all the arguments of the route() method, separated by commas:

GET /foo=class->method //ttl=0, kbps=0
GET /foo=class->method,86400 //ttl=86400, kbps=0
GET /foo=class->method,0,56 //ttl=0, kbps=56

To pass arguments, use the following syntax:

GET /foo/@arg1/@arg2=myClass->myMethod

The method will receive the parameters as a 2nd argument:

class myClass {
  function myMethod($f3,$params) {
    echo $params['arg1'];
    echo $params['arg2'];
  }
}

Concerning the cache, it is set globally, not for each route:

[globals]
CACHE=TRUE
like image 130
xfra35 Avatar answered Sep 21 '25 07:09

xfra35