phpillip / phpillip
Requires
- php: >=5.6
- erusev/parsedown: ^1.5
- silex/silex: ~1.3
- symfony/config: ~2.7
- symfony/console: ~2.7
- symfony/filesystem: ~2.7
- symfony/finder: ~2.7
- symfony/process: ^2.7
- symfony/serializer: ~2.7
- symfony/twig-bridge: ^2.7
- symfony/yaml: ~2.7
This package is not auto-updated.
Last update: 2020-11-27 12:41:18 UTC
README
Phpillip 是 Hugo 的近亲。
是什么
Phpillip 是一个用 PHP 编写的静态网站生成器,由 Silex 和 Symfony 组件 支持。
它基本上将你的 Silex 应用程序导出到 /dist
文件夹中的静态 HTML 文件。
结果目录旨在由像 apache 和 nginx 这样的 HTTP 服务器提供,或者发布到像 Github Pages 这样的静态网站服务。
它特别适合 博客、文档 和 展示。
如何
Phpillip 是一个 Silex 应用程序。
构建过程
- 遍历应用程序中声明的所有 路由
- 从文件中加载与路由关联的内容(如果有)
- 在 请求 中调用每个路由及其内容
- 将 响应 内容写入文件
它支持你需要的任何格式。
它使用强大的 Twig 模板引擎。
为什么
Phpillip 的目的是
- 高度 可扩展
- 对 Symfony 开发者友好
- 清晰、简单、干净
入门
获取你的静态网站
- 启动 Phpillip 项目
- 编写你的内容
- 声明你的路由和控制器
- 提供模板
- 构建静态网站
1. 启动
要启动一个新的 Phpillip 项目
composer create-project phpillip/phpillip-standard my_app
cd my_app
2. 编写内容
在 src/Resources/data/[my-content-type]/
中编写你的内容文件 [my-content-slug].[format]
示例 src/Resources/data/article/why-use-phpillip.md
---
title: Why use Phpillip?
---
# Why use Phpillip
Why not!
3. 声明路由和控制器
Phpillip 是一个 Silex 应用程序,因此你可以像在 Silex 中一样声明一个路由及其控制器
闭包
$this->get('/', function () { return []; })->template('index.html.twig');
在 'src/Controller' 中的自己的控制器类
$this->get('/blog', 'Controller\\BlogController::index');
控制器服务(这里是指 Phpillip 内容控制器服务)
$this->get('/blog/{post}', 'content.controller:show')->content('post');
Phpillip 为你提供了 许多助手,以自动为你的路由加载内容。
4. 提供模板
在 src/Resources/views/
中编写与您的路由和控制器相对应的 Twig 模板
如果您使用默认的 Phpillip 路由和控制器,则需要提供
列表模板
- 文件:
[my-content-type]/index.html.twig
。 - 变量: 一组内容,命名为
[content-type]s
。
{% extends 'base.html.twig' %} {% block content %} {% for article in articles %} <a href="{{ path('article', {article: article.slug}) }}"> {{ article.title }} </a> {% endfor %} {% endblock %}
单个内容页面模板
- 文件:
[my-content-type]/show.html.twig
。 - 变量: 以关联数组形式的内容,命名为
[content-type]
。
{% extends 'base.html.twig' %} {% block content %} {{ article.content }} {% endblock %}
5. 构建
使用 Phpillip 构建命令将静态文件构建到 /dist
bin/console phpillip:build
完成!
进一步学习
关于 Phpillip 的 特性
关于 内容
关于 控制器
关于 控制台
贡献
欢迎任何类型的 贡献!
目录结构
# Sources directory
src/
# Your Silex Application in which your declare routes, services, ...
Application.php
# Your controller classes (optional)
# This is only a recommandation, you can put controllers wherever you like
/Controller
MyController.php
# Resources
/Resources
# Configuration files directory
config/
# Phpillip configuration
config.yml
# Content directory
data/
# Create a directory for each content type
post/
# Your 'post' contents goes here
my-first-post.md
a-post-in-json.json
# Public directory
public/
# All public directory content will be exposed in 'dist'
css/
style.css
# Views directory
views/
# Your twig templates
base.html.twig
blog/
index.html.twig
show.html.twig
# Destination directory
dist/
# The static files will be dumped in here