mgdsoft/symfony-profiler-spa
Composer 安装命令:
composer require mgdsoft/symfony-profiler-spa
包简介
Symfony profiler enabled from vanilla js
README 文档
README
This bundle allows you to integrate the Symfony profiler bar into your preferred JavaScript framework.
Here's a quick installation guide
Install the bundle into your API PROJECT
composer req mgdsoft/symfony-profiler-spa --dev
Add the new route to your API PROJECT:
# config/routes/web_profiler.yaml when@dev: mgd_profiler_spa: resource: '@SymfonyProfilerSPABundle/Resources/config/routing/routing.yml' prefix: /
Create the asset or copy if you are not using asset component:
bin/console assets:install
This execution will copy 'load_toolbar_spa.js' file to your public folder, you only have to include it in your html file to your FRONTEND project:
<script src="//yourdomain.lol/bundles/symfonyprofilerspa/load_toolbar_spa.js"></script>
That's all! The load_toolbar_spa.js is created in vanilla JavaScript, so it's available for use in all frameworks and
libraries. Interceptors available for XHR and fetch.
JS Config
For custom url toolbar you have to use this custom attribute data-url-toolbar
<script src="//yourdomain.lol/bundles/symfonyprofilerspa/load_toolbar_spa.js" defer data-url-toolbar="{ORIGIN}/internal/toolbar/{TOKEN}"></script>
How it works
If you take a look inside src/Resources/public/load_toolbar_spa.js, you'll find a simple script that creates an HTTP
interceptor. The first x-debug-token-link header it detects will trigger a request to the API server to retrieve the
profiler.
Repo demo
Here is a repository installed and ready for testing: https://github.com/MGDSoft/symfony-profiler-spa-demo
Trouble with CORS
Dont forget your nginx configuration to avoid cors
add_header Access-Control-Allow-Origin "http://yourdomain.lol"; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; add_header Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept, Authorization, x-debug-token-link, X-Debug-Token"; add_header Access-Control-Expose-Headers "X-Debug-Token, X-Debug-Token-Link";
Cool things
Don't forget to configure your IDE to open errors/controllers, and for more information, please visit https://symfony.com/doc/current/reference/configuration/framework.html#ide. If you have trouble configuring PHPStorm, you can use this snippet for a quick solution.
parameters: env(SYMFONY_IDE): "javascript: (function () { let file = '%%f'; file = file.replace('/var/www/your-project/', ''); let newUrl = 'http://localhost:63342/api/file?file='+file+'&line=%%l'; fetch(newUrl); })()" framework: ide: '%env(SYMFONY_IDE)%'
Replace /var/www/your-project/ with the current path of your project. It works using relative paths, so it will work in Docker. For more information, please visit https://www.develar.org/idea-rest-api/."
Enjoy!
mgdsoft/symfony-profiler-spa 适用场景与选型建议
mgdsoft/symfony-profiler-spa 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 25.68k 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mgdsoft/symfony-profiler-spa 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mgdsoft/symfony-profiler-spa 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 25.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-04-06

