NostalgiaPHP — Developer Guide (for WP/PHP folks)
Quickstart
run locally (PHP 8+)
php -S localhost:8000
then visit http://localhost:8000
Add a New Page
- Create
content/pages/contact.md - Add front‑matter:
--- title: Contact --- ## Say hello Email us at hello@example.com. - Visit
/contact
Add a New Collection
- In
config.phpadd:'collections' => [ 'blog' => [ 'permalink' => '/blog/{slug}', 'list_url' => '/blog', 'sort' => ['date','desc'] ], 'projects' => [ 'permalink' => '/projects/{slug}', 'list_url' => '/projects', 'sort' => ['date','desc'] ], ], - Create folder:
content/collections/projects/ - Add an item:
content/collections/projects/first-project.md--- title: First Project date: 2025-09-06 --- Project body in **Markdown**. - Visit
/projects(list) and/projects/first-project(item).
Change the Navigation
Edit partials/header.php and add another <a> tag. No database, no menus UI — just HTML.
Common Customizations
1) Real Markdown Parser
Drop Parsedown.php into the project and swap markdown_to_html() to use it:
require_once __DIR__ . '/Parsedown.php';
$p = new Parsedown();
return $p->text($md);
2) Drafts
Hide items from lists when draft: true:
// inside list_collection(), filter $items where meta['draft'] !== true
$items = array_filter($items, fn($it) => empty($it['meta']['draft']));
3) Excerpts
Add excerpt: in front‑matter and show it on collection list pages.
4) RSS for a Collection (sketch)
Create /rss.php that reads list_collection('blog'), renders an XML feed, and link to it in header/footer.
Security Notes
- Content is trusted; still, we do
htmlspecialchars()for titles and links. - If you ingest user input, sanitize aggressively and disable raw HTML in Markdown.
Nginx Example
location / {
try_files $uri $uri/ /index.php;
}
WordPress Mapping
- Theme files →
templates/+partials/ - The Loop →
list_collection()+ foreach - Template Tags → helpers in
functions.php - Permalinks →
.htaccess(Apache) ortry_files(Nginx) - Custom Fields → front‑matter keys
Style Guide (Tiny)
- Keep helpers in
functions.phpsmall and pure where possible. - Prefer configuration in
config.phpover conditionals in templates. - Keep
index.phpdumb (routing only).
Testing Tips
- Manual: create pages/items and verify routes
/,/about,/blog,/blog/slug. - Automated (optional): write small PHPUnit tests for front‑matter parsing and collection sorting.