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

StackOverflow https://stackoverflow.com/questions/22529740

  •  17-06-2023
  •  | 
  •  

문제

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