PHP code example of efficience-it / speedtest-bundle
1. Go to this page and download the library: Download efficience-it/speedtest-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
class HomeController extends AbstractController
{
/**
* @Route("/home", name="app_home")
*/
public function index(SpeedtestService $speedtestService): Response
{
// Replace 'home/index.html.twig' with the name of your template
return $this->render('home/index.html.twig', [
'speedtest' => $speedtestService->displaySpeedtest()
]);
}
}
{% extends 'base.html.twig' %}
{% block title %}Hello HomeController!{% endblock %}
{% block body %}
{%
/* DON'T ADD A @Route ANNOTATION */
class ResultsController extends AbstractController
{
/* DON'T CHANGE THIS ROUTE ! */
/**
* @Route("/speedtest-results", name="speedtest_results", methods={"POST"})
*/
public function speedtestResults(Request $request): Response
{
if (!$request->isXmlHttpRequest()) {
throw new AccessDeniedException();
}
$requestContent = json_decode($request->getContent(), true);
dump($requestContent);
return new JsonResponse($requestContent);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.