PAGENODE

About Documentation Github

No Bullshit Content Management

Pagenode is a PHP Content Management Library for static sites using flat files for storage. It allows for great flexibility with custom routing and a simple query interface.

Pagenode runs on PHP7, has no dependencies and comes in a single file weighing in at 2700 lines of code (2000 of which belong to the Markdown parser), totalling 56kb.

This makes Pagenode a good fit for your personal blog, portfolio site or product page. If you want to give it a try please read the Getting Started Guide.

Pagenode is not revolutionary in any way. It brings nothing new to the table. Instead, it removes everything that is unnecessary. I wrote an in-depth discussion about Pagenode and why it exists in my Blog.

Synopsis

Load up Pagenode

<?php
require_once('pagenode.php');

define a route, select some files, load a template

route('/blog/page-{page}', function($page) {
    $posts = select('blog/posts/')->newest(5, ['page' => $page]);
    include('templates/blog/list.html.php');
});

and let Pagenode handle the current request.

dispatch();

Example

Here's the source for this very website

<?php
require_once('pagenode.php');

// Handle all requests with a single keyword parameter
// by trying to find a matching file.

route('/{keyword}', function($keyword) {
    $node = select('nodes/')->one(['keyword' => $keyword]);
    if (!$node) {
        // Returning false in a route handler means this request
        // hasn't been handled here and will 404
        return false;
    }

    include('templates/node.html.php');
});


// Internally re-route an empty request URL to the "welcome" node, 
// which will be handled above.

reroute('/', '/welcome');


// Ordering of routes is important. By specifying a "catchall" 
// route last we can use it as our 404 handler.

route('/*', function(){
    include('templates/404.html.php');
});

dispatch();

Try Pagenode for yourself »

© 2024 Dominic Szablewski – rendered in (3.77ms)