spontaneit / static-content-bundle
生成静态页面
v0.8
2023-12-18 09:54 UTC
Requires
- php: >=8.0
- doctrine/orm: ^2
- symfony/browser-kit: ^5.4 || 6.4.*
- symfony/console: ^5.4 || 6.4.*
- symfony/framework-bundle: ^5.4 || 6.4.*
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}