fw/last-bundle
Composer 安装命令:
composer require fw/last-bundle
包简介
Static site generator for any Symfony 4 project.
README 文档
README
Last is a minimalistic static site generator for Symfony 4 applications. Once installed, Last provides a command that will simply create requests for all of your routes and dumps the result as a static file to a dist folder.
Installation
(A symfony/flex recipe will be created soon. )
composer require fw/last-bundle
Last should get registered automatically to config/bundles.php. If not, add it by hand:
...
Fw\LastBundle\FwLastBundle::class => ['all' => true],
Usage
Now you can run the dump command and your Symfony app gets exported as static html files.
# will dump to the configured dist folder, defaults to %project%/dist
bin/console last:dump
# wil dump to the given folder
bin/console last:dump --dist=./custom_dist_folder
Is it production ready?
Soon, however the following is missing yet:
- Test with more real life projects
- Provide an symfony/flex recipe
- Automatically copy assets from public/build, public/bundles/* and other locations to dist folder after dumping
Configuration
fw_last:
dist_folder: '%kernel.project_dir%/dist' # this is the default dist folder, if you don't set it
providers:
static: true # Static provider is enabled per default, you can disable it here
Request providers
Last runs requests against your kernel. So in order to make it work, all desired requests must be defined. To make things more easy, Last comes with a request provider for all static routes (routes without mandatory placeholders). So you only need to implement a custom request provider if you want to include dynamic routes like blog/article/{id}. A simple provider could look like this:
use Fw\LastBundle\Router\RouteProvider;
class YourustomProvider implements RouteProvider
{
/**
* {@inheritdoc}
*/
public function getRoutes(): array
{
return [
Request::create('blog/article/1'),
Request::create('blog/article/2'),
Request::create('blog/article/3'),
];
}
}
And needs to be a tagged service, in order to make it visible for Last.
Your\CustomBundle\Provider\CustomProvider:
tags: ['fw.last.route_provider']
Of course you can inject any dependencies like an entity manager to create more advanced providers.
Troubleshooting
My links start with http://localhost/ what should I do?
Use {{ path() }} instead of {{ url() }} in your templates to make your urls relative.
fw/last-bundle 适用场景与选型建议
fw/last-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 149 次下载、GitHub Stars 达 11, 最近一次更新时间为 2018 年 08 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 fw/last-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 fw/last-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 149
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-08-28