4 ms·
I fit into that Paradox -- I rewrote my own personal website in modern PHP without a framework or database. It's mostly a static site but uses PHP to add heade
by wvenable 2y ago
I fit into that Paradox -- I rewrote my own personal website in modern PHP without a framework or database. It's mostly a static site but uses PHP to add headers, deal with lists (for blog posts), etc. I found it slightly more convenient to be not completely static. I can just write up an article, commit, push, and it's online. I found most static site generators to be far too complicated.
The code for a single page looks like this:
<?php
$this->title = "Blog Article Title";
$this->shortTitle = "Title";
$this->date = mktime(0,0,0,1,27,2024);
if ($this->mode == PageMode::Meta) return;
?>
<p>Raw HTML content here<p>
There is a router that automatically adds the site header and footer, and I can add a "_layout.php" file to a folder to add another level of layout for child pages. For blog list page, it just scans all the individual article files in the folder to create the index. That where that $this->mode == PageMode::Meta comes in -- it executes the code in each file (to get the meta data) and then exits before rendering the rest. It's not going to scale to a lot of content but I'll adjust if it becomes an issue.
The entire PHP code for my "framework" is only 4 PHP files (init.php, functions.php, Layout.php, and Page.php).
The advantage of being a developer is that you can use code instead of configuration or data. And you can use code to write content more efficiently.
The result (still quite incomplete) is this: https://www.codaris.com/ https://www.codaris.com/
- ohpls 2y agoI've just started doing the same for one of my websites, 90% html but php for headers and include() for a few odd global bits.