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?

有帮助吗?

解决方案

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
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top