symfony - API driven symfony2 project -


im trying create api driven project in symfony2 using fosrestbundle.

i have apicontroller action getdataaction().

this works when send requests external application.i json encoded data expected.

but i'll needing data in same application well(i.e. other controller within same application).

which appropriate method of doing this?

  • creating object of apicontroller , calling required action on it. or
  • or sending curl request other controller getdataaction() of apicontroller data.

you can data apicontroller using route forwarding . using can use action in controller. no need curl or separate controller object. thing :

 $details = $this->forward('acmerestbundle:api:getdata',array('_format'=>'json')); 

that return result-set action.may :

  content":protected]=>   string(107181) "{}"   ["version":protected]=>   string(3) "1.0"   ["statuscode":protected]=>   int(200)   ["statustext":protected]=>   string(2) "ok"   ["charset":protected]=>   null 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -