ryanve / chromosome
基于JSON的PHP模板引擎
dev-php
2014-02-02 03:05 UTC
Requires
- php: >=5.4
- ryanve/slash: ~3.0.0
- ryanve/traits: ~0.8.0
Suggests
- ryanve/phat: >=2.5
This package is not auto-updated.
Last update: 2024-09-28 16:09:16 UTC
README
- 从存储在静态JSON和HTML文件中的内容生成视图。
- 用作服务器端模板引擎或本地站点生成器。
设置
Apache
将以下Apache重写添加到您的服务器根目录下的.htaccess文件中。根据需要更改_items
或_php
路径以适应您的目录结构。
# BEGIN chromosome # github.com/ryanve/chromosome <IfModule mod_rewrite.c> RewriteEngine On # Option 1: Unless file, add trailing slash. # RewriteCond %{REQUEST_FILENAME} !-f # RewriteRule ^.*[^/]$ /$0/ [L,R=301] # Option 2: Unless dir, remove trailing slash. RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)[/]+$ /$1 [L,R=301] # Search _items for non-existing URIs and rewrite if it exists there. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/_items/%{REQUEST_URI} -d RewriteCond %{DOCUMENT_ROOT}/_php/chromosome -d RewriteRule ^(.*)$ /_php/chromosome/request.php?request=$1&from=_items [L] # Map direct file requests. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{DOCUMENT_ROOT}/_items/%{REQUEST_URI} -f RewriteRule ^(.*)$ _items/$1 [L] # Rewrite other dirs that contain the JSON file. RewriteCond %{REQUEST_FILENAME} -d RewriteCond %{REQUEST_FILENAME}item.json -f RewriteCond %{REQUEST_URI} !^/?_items/.+$ RewriteRule ^(.*)$ /_php/chromosome/request.php?request=$1 [L] </IfModule> # END chromosome
许可证
MIT