For over a decade, if you wanted to start a blog, you were shoved into one of two boxes. You either wrestled with WordPress and its endless ecosystem of bloated plugins that eventually broke your site, or you settled for Blogger, a platform that feels frozen in the early 2010s. Neither felt fast, modern, or truly mine. So, I decided to build RogueDesk—an open-source, block-based CMS written from scratch in modern PHP.

RogueDesk isn't just a frontend skin; it's a complete architectural rebuild. It’s built for developers who want clean code, fast load times, and total control over their content. Here’s a deep dive into the technical architecture and features that make RogueDesk tick.

The Core Architecture

At its heart, RogueDesk uses a lightweight, custom MVC (Model-View-Controller) architecture. There is no heavy framework overhead. The entry point (`index.php`) handles autoloading, session management, and routing in a fraction of the memory that traditional CMS platforms use.

ComponentTechnology UsedPurpose
BackendPHP 8.2+ (OOP)Core logic, routing, and controllers
DatabaseMySQL via PDOSecure, prepared-statement data persistence
Frontend UITailwind CSS + Alpine.jsReactive, lightweight admin dashboard
EditorEditor.jsBlock-based JSON content creation

One of the most interesting pieces of the core is the custom Regex Router. It maps clean, SEO-friendly URLs to controllers without relying on a bloated routing library. It parses the URL, matches it against defined routes, and extracts parameters (like slugs) dynamically.

// Convert {slug} to regex pattern using ~ as delimiter
 $routePattern = preg_replace('~\{([a-z]+)\}~', '([^/]+)', $route['uri']);

if ($route['method'] === $_SERVER['REQUEST_METHOD'] && preg_match('~^' . $routePattern . '$~i', $uri, $matches)) {
    list($controller, $method) = explode('@', $route['action']);
    $instance = new $controller();
    call_user_func_array([$instance, $method], $matches);
    return;
}

The Editor: JSON, Not Messy HTML

WYSIWYG editors are inherently insecure. They output raw HTML, leaving your application vulnerable to XSS attacks and broken layouts. RogueDesk takes a different approach: it outputs structured JSON.

When you write a post in RogueDesk, you are using a modern, block-based editor. Instead of nesting `<p>` and `<span>` tags with inline styles, the editor saves a clean JSON array of blocks. A custom PHP parser then securely converts this JSON into beautiful, sanitized HTML for the frontend. This guarantees your posts will look stunning on any device and prevents malicious code from ever hitting your database.

Advanced blocks available out of the box:

  • - Text formatting (Headers, Paragraphs, Inline Markers)
  • - Media (Drag-and-drop AJAX image uploads, YouTube embeds)
  • - Developer tools (Syntax-highlighted Code blocks)
  • - Layout (Dynamic Tables, Delimiters)
  • - Engagement (Callout/Warning boxes, Checklists, Quotes)

Dynamic Theming System

A CMS is nothing without a way to customize the frontend. RogueDesk features a dynamic theme engine. Instead of hardcoding views, the `BlogController` scans a `/content/themes/` directory.

To create a new theme, you simply drop a folder into the directory containing an `index.php`, `post.php`, and a `theme.json` file. The admin dashboard automatically detects it, displays a preview card, and lets you activate it with a single click. The controller dynamically loads the active theme's files, passing the post data directly to the view. No database queries required to find the theme; just native PHP file system operations.

Drag-and-Drop Plugin Engine

The final piece of the puzzle is the widget system. I wanted to avoid the "hook hell" that plagues other platforms. RogueDesk uses a drag-and-drop interface powered by SortableJS.

When you drag a plugin (like "Recent Posts" or "Social Links") into a theme sidebar, an AJAX request fires, instantly saving the layout to the database. On the frontend, the theme simply loops through the active widgets for that area and calls a standardized render function. Building a custom plugin is as easy as creating a folder and defining a single function.

public static function renderWidget($key, $db) {
    $pluginFile = BASE_PATH . '/content/plugins/' . $key . '/plugin.php';
    
    if (file_exists($pluginFile)) {
        require_once $pluginFile;
        $functionName = 'render_' . $key;
        if (function_exists($functionName)) {
            return $functionName($db);
        }
    }
    return '<!-- Plugin missing -->';
}

Unchained and Open Source

RogueDesk is fast, secure, and completely extensible. It runs on standard shared hosting, requires zero build steps, and can be fully audited in an afternoon. It’s a return to the roots of the web: open, unchained, and built by developers, for developers.

The code is clean, the editor is polished, and the platform is yours. Welcome to the new era of blogging.