I plan to add access to android & ios developers to content form Symfony 3 data. Now, access is by web browser. I've expanded logic on Controller but sharing is simple by TWIG/HTML pages. ex.
/**
* Class DefaultController
*
* @Route("/item")
*
* @package SameBundle\Controller
*/
class DefaultController extends Controller
{
/**
* Lists all Product entities.
*
* @Route("/", name="product_index")
* @Method("GET")
*
* @Template
*/
public function indexProductAction()
{
// (...)
return ['products' => $products,];
}
It is supported by the indexProduct.html.twig page.
What do I have to add to controller/function to doing it?
To server mobile devices you will need to send them json instead of html. So in your controller you can check if the request comes from the browser then you return html as you do it usually, and if request comes from mobile app then return json response:
return new JsonResponse($myresponse);