https://github.com/slogsdon/php-flat-file
Fast static-site generator / flat-file CMS
https://github.com/slogsdon/php-flat-file
flat-file-cms static-site-generator zero-configuration
Last synced: 12 months ago
JSON representation
Fast static-site generator / flat-file CMS
- Host: GitHub
- URL: https://github.com/slogsdon/php-flat-file
- Owner: slogsdon
- License: mit
- Created: 2018-07-20T06:16:18.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2024-12-30T04:49:02.000Z (over 1 year ago)
- Last Synced: 2025-06-13T23:38:32.382Z (about 1 year ago)
- Topics: flat-file-cms, static-site-generator, zero-configuration
- Language: PHP
- Homepage: https://packagist.org/packages/slogsdon/flat-file
- Size: 84 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-static-generators - php-flat-file - A flat-file CMS and static site generator with no database, no configuration, and Markdown content. - `#PHP` `#Markdown` (Uncategorized / Uncategorized)
README
# flat-file
[](https://packagist.org/packages/slogsdon/flat-file)
[](https://packagist.org/packages/slogsdon/flat-file)
[](https://packagist.org/packages/slogsdon/flat-file)
[](https://packagist.org/packages/slogsdon/flat-file)
[](https://travis-ci.com/slogsdon/php-flat-file)
[](https://codeclimate.com/github/slogsdon/php-flat-file/maintainability)
[](https://codeclimate.com/github/slogsdon/php-flat-file/test_coverage)
> Fast static-site generator / flat-file CMS
[View an example project.](https://github.com/slogsdon/php-flat-file-starter)
### 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
- [PHP 7.1+](http://www.php.net/)
- [Composer](https://getcomposer.org/)
## Getting Started
```json
{
"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 `` tags, etc.) or returning the content as a string (`
Hello World
```
Add more pages with new files under `pages`, e.g.:
```markdown
# 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
F5/Cmd-R for the time being.## License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.