We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Static Site Generator in Phalcon

Is there any existing "Static Site Generators" written in phalcon php ? It would be a nice example to new phalcon users. Using phalcon micro to generate static files out of markdown. With good directories stracture. If any one interested in coding this, here is some ideas of features and directory stracture. It can be called something like "Phalcon Generator" or simply "PhalGen". Using phalcon to generate static pages could be one of the fastest static generators available right now.

Rules of Thumb:

  • Must use phalcon framework of course.
  • Must not use any database, should only be flat-file.
  • Must be open source (MIT or GPL)
  • Must be fast and secure.
  • Must be SEO friendly urls.
  • Files should be YYYY-MM-DD-some-page-title.md
  • Should support markdown. Example Here

Important Features:

  • Markdown static files for Content
  • Using CSS Bootstrap
  • Using Volt for Templates
  • Using Volt Cache (if enabled)
  • Have pagination for blog.
  • Generate menu for pages.

Useful Features:

  • RSS Feed for blog posts.
  • Sitemap XML for search engines.
  • Minify CSS and JavaScript source code.
  • Have friendly "print" view for printing pages/posts.
  • Proper meta and keywords tags in markdown files.
  • More shortcode tag kind of like wordpress "more" tag, using shortcode.
  • In page "pagination" for very long pages or posts, using shortcode.

Optional Features:

  • PDF generator for pages and posts.
  • GitHub Gists shortcode. {git} some code {/git}
  • Source code highlighting. {code} some code {/code}
  • Basic HTTP Auth or In page form authentication for selected pages.
  • MarkItUp Editor (only useful if admin cp is created)
  • Admin and Users CP (but this can be seperate addon)

Example Markdown File:

Any markdown special tags can be optionally used.

Title: Some Title Here
Author: John Doe Smith
Tags: tag one, tag two, tag three
Description: Some page description
Keywords: keword one, keyword two
Layout: SomeTemplate (to set other layout then default)
Menu: None (if you dont want page apearing in navigation)

Any markdown or regular html here.

Example Directory Stracture:

Application Directories & Files:
  • /app/ -- main phalcon php application directory.
    • /app/config/ -- main config directory.
      • /app/config/config.php -- app config file.
      • /app/config/routes.php -- app routes file.
    • /app/cache/ -- to store volt cache if enabled in config.
    • /app/controllers/ -- any controllers
      • /app/controllers/IndexController.php -- index controller.
      • /app/controllers/PageController.php -- pages controller.
      • /app/controllers/PostController.php -- posts controller.
    • /app/models/ -- any models (if needed)
    • /app/views/ -- any volt views
      • /app/views/header.phtml -- include header
      • /app/views/footer.phtml -- include footer
      • /app/views/error.phtml -- error 404 page
      • /app/views/home.phtml -- site home page
      • /app/views/page.phtml -- site page
      • /app/views/main.phtml -- blog index page
      • /app/views/post.phtml -- blog post page
      • /app/views/archive.phtml -- archive page for blog posts.
Public Directories & Files:
  • /pub/ -- main phalcon php public directory.
    • /pub/index.php -- bootstrap file.
    • /pub/content/ -- main content directory.
      • /pub/content/pages/ -- markdown pages for site directory.
      • /pub/content/posts/ -- markdown posts for blog directory.
    • /pub/static/ -- main phalcon static files directory.
      • /pub/static/img/ -- images directory.
      • /pub/static/css/ -- stylesheet directory.
      • /pub/static/js/ -- javascript directory.

Thank You for reading this :-) Please vote and if you code something like this share it here.


edited Jan '15

No Cryogen looks completely different and its not coded on top of Phalcon php. I don't think it uses php at all lol

edited Feb '16

Nah, I don't think there's something like it. I've been doing research on the same topic, and none of the available solutions matches what I'm looking for. I think I'll be coding it myself in the end.. Plus, I have some additional requirements:

  • When generating the complete files, it should be intelligent enough to regenerate all pages when I'm editing a header/footer, and current file only when I'm editing a blog post
  • Should support markdown extra
  • Should be easily themeable
  • Still wondering if I should go with a hybrid solution, using sqlite for easy searching through the content, and static files for direct url hits.
  • Should have a rudimentary admin panel for interfacing with config files.

TuxLyn, are you interested in using such a thing, or writing it? :)

Btw, the phalcon blog on github is a really good starting point. Go check it out: https://github.com/phalcon/blog