spontaneit/static-content-bundle

生成静态页面

安装: 21

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

公开问题: 0

类型:symfony-bundle

v0.8 2023-12-18 09:54 UTC

This package is auto-updated.

Last update: 2024-09-18 11:33:42 UTC


README

从 symfony 路由生成静态页面

配置

在您的 config/packages 文件夹中添加 static_content.yaml 文件

static_content:
  target_folder: static
  included_routes: []
  excluded_routes: ['app_logout', 'app_login']
  excluded_prefix_routes: ['ajax', 'admin']

使用 included_routes 仅生成这些路由的静态内容,或使用 excluded_routes 和/或 excluded_prefix_routes 为所有路由生成静态内容,但不包括排除的

编辑 .htaccess

将以下内容添加到 /public/.htaccess 文件中以自动提供静态页面

    RewriteCond %{DOCUMENT_ROOT}/static/%{REQUEST_URI}.html -f [NC]
    RewriteRule ^ static/%{REQUEST_URI}.html [L]

其中 static 是配置文件中的默认 'target_folder' 参数

Doctrine 实体

要为具有例如 slug 属性的 doctrine 实体生成静态页面,您必须设置参数名称如下:{myentity_slug}