Skip to content

slogsdon/php-flat-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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).

Don't forget to pull down your dependencies:

composer install 

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

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:

composer build 

Ignoring Composer's vendor directory, you should see something similar to below in your project root:

. ├── composer.json ├── composer.lock ├── dist │ ├── about.html │ └── index.html ├── pages └── vendor 

F.A.Q.

What about LiveReload like functionality?
That's being investigated, but use `F5`/`Cmd-R` for the time being.

License

This project is licensed under the MIT License. See LICENSE for details.

About

Fast static-site generator / flat-file CMS

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages