StaticPHP

StaticPHP

What is a Static Site?

A static site is where the website content is controlled solely by the developer/owner of said website, and does not depend on any other influences like access to a database, server side processing, or user input such as a search feature, or authentication and authorisation.

Why did I make StaticPHP?

For many years, I have been making websites that are basically static, but were powered by PHP to make some tasks easier, such as maintaining the same design and layout across all pages, making it easy to update site-wide navigation, and some things like conditionals and loops to save duplicating code and to save time.

It wasn't until 2022 that I realised how much energy was being wasted by the server preparing and generating each page for each request when it didn't have to. I found a better way to make these static sites, and that was to use a Static Site Generator.

After some time trying out an SSG I found online, it wasn't long before I started missing coding in PHP, because that's what I've been doing all along, so I made the decision to develop my very own static site generator to suit my needs, and hopefully suit yours too.

Why use StaticPHP?

It gives you the freedom to code your site however you want, using whatever PHP code you want, which lets you be efficient during development, while deploying a fully static site to your hosting server. If you don't generate the static site on the server, then the server itself does not need PHP installed for your site to work.

How does StaticPHP work?

It takes any PHP file and processes it. Except without presenting the output onto the screen, it saves the output to a file. Any non-PHP file is simply copied to the designated output directory, so your asset files like images and CSS etc will still work fine.

With the addition of the MetaData feature and support for HTML files, you can now develop your site without writing any PHP code or creating any PHP files if you don't want to.

You can set Friendly URLs to true in your build configuration to have the output be an index.html file placed inside a folder with the same name as the input file minus the extension. This lets you have urls such as domain.tld/page instead of domain.tld/page.html. This setting can be overridden on a per-page basis by setting the boolean variable $friendly_urls or the Special MetaData key friendly_urls to true to enable it or false to disable it.