slogsdon/flat-file
Composer 安装命令:
composer require slogsdon/flat-file
包简介
Fast static-site generator / flat-file CMS
README 文档
README
shane.logsdon.io — writing and projects on agentic workflows, web standards, and payments engineering.
flat-file
Fast static-site generator / flat-file CMS
Features
- Needs zero configuration
- Uses Markdown, HTML, or PHP
- Routes based on file system
- Exports static sites, or runs via PHP powered web servers
- Includes development environment
Reasoning
PHP is easy to install, if not already present on you computer. PHP runs pretty much everywhere. PHP is flexible.
This project also scratches an itch to see how much PHP can handle in this problem domain.
Requirements
Getting Started
{
"name": "user/site",
"description": "",
"require": {
"slogsdon/flat-file": "dev-master"
},
"scripts": {
"build": "flat-file build",
"start": "flat-file serve"
},
"config": {
"process-timeout": 0
}
}
The scripts and config sections are not required, but they do help simplify the development process. If using the start script, the process-timeout configuration option allows Composer to run a script for longer than the default timeout (300 seconds).
If not using Composer script configurations, you'll need to reference the flat-file script as vendor/bin/flat-file, e.g.:
vendor/bin/flat-file build
vendor/bin/flat-file serve
After setting up your composer.json file, don't forget to pull down your dependencies:
composer install
Adding Content
Next, your individual pages need to be included in a pages directory at the root of your project (i.e. next to your composer.json file). Pages can be written in Markdown (with the .md or .markdown file extension), plain HTML, or PHP (with the .php file extension). PHP files have the option of outputing the content as normal (echo, print, content outside of <?php ?> tags, etc.) or returning the content as a string (<?php return 'hello world';).
<?php /* pages/index.php */ ?> <h1>Hello World</h1>
Add more pages with new files under pages, e.g.:
<!-- pages/about.md --> # About
Running the Development Server
Ready to test? Spin up the development server:
composer start
This will start a PHP development server listening on http://localhost:3000. Pressing Ctrl-C will stop the server, freeing the way for building your project to plain HTML files for later deployment.
Building Static Files
Kick off a build of the site:
composer build
Ignoring Composer's vendor directory, you should see something similar to below in your project root once all is said and done:
.
├── composer.json
├── composer.lock
├── dist
│ ├── about.html
│ └── index.html
├── pages
└── vendor
Using a Custom Entrypoint
By default, we provide an entrypoint for the webserver to use when serving requests. It completes some rewrites for files in public, requires the Composer autoloader, and kicks off the application. You can elect to include your own by creating a new entrypoint named index.php and put it in the public directory at the root of your project. Here's the default one for reference:
<?php declare(strict_types=1); $uri = $_SERVER['REQUEST_URI']; if ($uri !== '/' && file_exists(getcwd() . '/public' . $uri)) { return false; } require getcwd() . '/vendor/autoload.php'; new FlatFile\Application;
Running as a Flat-File CMS
If you wish to run your project with a PHP-enabled web server as a flat-file CMS instead of a static site, you'll want to:
- Configure your web root to be
public - Use a custom entrypoint or configure your web server to have
vendor/slogsdon/flat-file/src/router.phpserve any non-existent paths.
Your web server will then be able to serve static assets from public as it normally would and also any pages you create.
F.A.Q.
- What about LiveReload like functionality?
- That's being investigated, but use
F5/Cmd-Rfor the time being.
License
This project is licensed under the MIT License. See LICENSE for details.
slogsdon/flat-file 适用场景与选型建议
slogsdon/flat-file 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 209 次下载、GitHub Stars 达 5, 最近一次更新时间为 2018 年 07 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 slogsdon/flat-file 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 slogsdon/flat-file 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 209
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-07-20