makinacorpus/static-passthrough-bundle
Composer 安装命令:
composer require makinacorpus/static-passthrough-bundle
包简介
Easily serve a tree of statics files through Symfony
README 文档
README
This bundle has been developed for a simple use case : serve static files (e.g. generated documentation) through a Symfony application.
Getting started
1/ Install with Composer:
composer require makinacorpus/static-passthrough-bundle
2/ Register the bundle
# config/bundles.php return [ // ... MakinaCorpus\StaticPassthroughBundle\StaticPassthroughBundle::class => ['all' => true], // ... ];
3/ Add Static Passthrough Routes definition
# config/routes.yaml # ... static_passthrough: resource: "@StaticPassthroughBundle/Resources/config/routes.php" # ...
4/ Configure Static Passthrough
Let's assume we have a docs folder in the root directory of our application, with a simple test.html file in it:
that's the static file we want to serve through our Symfony app.
To do so, configure the bundle like this:
# config/package/static_passthrough.yaml static_passthrough: definitions: docs: # Route name will be 'static_passthrough_docs' root_folder: 'docs' # Where to find files to passthrough (this path has to be relative to %kernel.project_dir%) path_prefix: 'docs/' # Path to reach files in root_folder
Don't forget to clear the cache:
bin/console c:c
5/ Reach the file with your browser :
Visit [app_basepath]/docs/test.html, you should see your HTML file appear.
Note that you could also view it visiting [app_basepath]/docs/test,
in fact when you try to visit [app_basepath]/docs/test, the bundle will look for a file in these different paths, in that order:
[app_basepath]/docs/test[app_basepath]/docs/test.html[app_basepath]/docs/test/index.html
6/ Generate URL
Here is an examples to create an URL to reach 'test.html' file described above:
From a controller:
$this->generateUrl( 'static_passthrough_docs', ['path' => 'test.html] );
From twig:
{{ path('static_passthrough_docs', {'path': 'test.html'}) }}
makinacorpus/static-passthrough-bundle 适用场景与选型建议
makinacorpus/static-passthrough-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 47.91k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2020 年 07 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 makinacorpus/static-passthrough-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 makinacorpus/static-passthrough-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 47.91k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-07-21