efficience-it/speedtest-bundle
Composer 安装命令:
composer require efficience-it/speedtest-bundle
包简介
Speedtest
README 文档
README
This speedtest is a Symfony-based bundle. It's an overhaul of the LibreSpeed project.
It was created by Efficience IT, a French company located in Lille.
Installation
Step 1: Install the bundle with Composer
Require the efficience-it/speedtest-bundle with Composer.
$ composer require efficience-it/speedtest-bundle
Step 2: Configure the speedtest in your project
First, verify if the line below is in the bundles.php file. If not, copy and paste it.
EfficienceIt\SpeedtestBundle\SpeedtestBundle::class => ['all' => true]
Second, create the speedtest.yaml file in the config/routes folder.
Copy the code below and paste it in this file.
speedtest: resource: '@SpeedtestBundle/Resources/config/routes.yaml' prefix: /speedtest
Step 3: Add the speedtest on your website
On any controller, you can call the SpeedtestService and its displaySpeedtest function.
Here is an example of a controller, with a route tht includes the bundle:
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() ]); } }
To display the speedtest on your page, just include it in your template file as below:
{% extends 'base.html.twig' %}
{% block title %}Hello HomeController!{% endblock %}
{% block body %}
{% include speedtest %}
{% endblock %}
You can access to your route (in this example localhost/home), and the speedtest should appear !
How to retrieve the results ?
Create a new Controller (for example ResultsController), and copy/paste this code:
/* 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); } }
With this route (called in AJAX), you can retrieve your speedtest results and do whatever you want with it !
Change the bundle language
Find the config/packages/translation.yaml. You just have to change the default_path parameter with the language you want.
Actually, you can translate in English (en) and French (fr). Here is an example of the translation.yaml file with French configuration.
framework: default_locale: fr # Change the language here translator: default_path: '%kernel.project_dir%/translations' fallbacks: - en # Default language if the default_locale is not found.
efficience-it/speedtest-bundle 适用场景与选型建议
efficience-it/speedtest-bundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 10 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 efficience-it/speedtest-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 efficience-it/speedtest-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-10-18