<?phpnamespaceAppBundle\Controller;useSensio\Bundle\FrameworkExtraBundle\Configuration\Route;useSymfony\Bundle\FrameworkBundle\Controller\Controller;classLastWeekDataControllerextendsController{/** * @Route("/LastWeekData", name="LastWeekData") */publicfunctionGetAllData(){// Get cURL resource$curl=curl_init();curl_setopt($curl,CURLOPT_URL,"https://pollutometerapi.azurewebsites.net/api/Readings/lastweek");curl_setopt($curl,CURLOPT_HTTPHEADER,array('Content-type: application/json'));// Assuming you're requesting JSONcurl_setopt($curl,CURLOPT_RETURNTRANSFER,1);// Send the request & save response to $resp$resp=curl_exec($curl);// Close request to clear up some resourcescurl_close($curl);$data=json_decode($resp,true);usort($data,function($a,$b){return$a['TimeStamp']-$b['TimeStamp'];});foreach($dataas$index=>$item){$data[$index]['TimeStamp']=gmdate("l jS \of F Y h:i:s A",$item['TimeStamp']);}$parametersToTwig=array("data"=>$data);return$this->render('default/LastWeekData.html.twig',$parametersToTwig);}}