Nipaa's Blog

🐘 NanoMVC Framework

A minimalist and lightweight PHP MVC framework inspired by TinyMVC — use it for small to medium projects with minimal configuration.

Overview

NanoMVC is a cleaned-up, modernized fork of the original TinyMVC framework. It keeps the original simplicity and structure while updating internals for PHP 8.3+ and adding pragmatic enhancements. NanoMVC is intended for developers who prefer control, clarity, and a lightweight foundation rather than a large, opinionated stack.

What NanoMVC Gives You

  • Clear MVC separation (Model — View — Controller)
  • PDO-based database layer (MySQL, PostgreSQL with port/schema support)
  • Simple plugin system for extensions and helpers
  • Safe customization points so you can extend core behavior without forking it permanently

What NanoMVC Is Not

NanoMVC is not a full-stack framework like Laravel or Symfony. It intentionally avoids large built-in subsystems (ORMs, queues, heavy middleware). Instead it focuses on being predictable, small, and extensible.

Key Features

  • Minimalist — no unnecessary complexity or dependencies.
  • PHP 8.3+ ready — modern syntax and compatibility fixes.
  • Case-insensitive routing while preserving original URL casing for controller/action access.
  • Extensible plugin model — load helpers, libraries, and models via config or controller code.
  • Improved error handling with customizable view templates for HTTP status codes.

Recent Highlights

v1.0.3 — Overhauled error handler, new URI and Script Helper plugins, BlogMenu plugin to create blogs without a database, and other refinements.

v1.0.2 — Core split into NanoMVCCore.php (base class), case-insensitive routing, autoload model improvements, PostgreSQL support, and a redesigned welcome view.

Project & Documentation

Repo: https://github.com/​Makareene/NanoMVC

Documentation and guides are available at: https://nanomvc.nipaa.fyi

Project Structure (typical)

app/
  configs/
  controllers/
  models/
  views/
  plugins/
myfiles/
  configs/
  controllers/
  models/
  views/
  plugins/
sysfiles/
  configs/
  controllers/
  models/
  views/
  plugins/

Installation (quick)

  1. Download the repository from GitHub.
  2. Place files in your project root.
  3. Edit /configs/​config_application.php with base URL and settings.
  4. Configure database in /configs/config_database.php if required.
  5. Point your web server document root to the /public folder.
  6. Change paths in your index.php file.

Core Concepts

Controllers — map URLs to controller/method/params. Controller names are case-insensitive in routing; original casing is available via $this->_get_controller() and $this->_get_action().

Views — simple rendering layer. Use view helpers to assign variables and display templates.

Models — PDO-backed data layer. Works with MySQL and PostgreSQL (includes port/schema options).

Plugins — small libraries you can load from config or controllers. Examples: URI helper, Script helper, BlogMenu.

BlogMenu — blog without a DB or any storage system

The BlogMenu plugin builds categories and articles straight from controller files and method PHPDoc metadata — no database required. Metadata format:

Controller category (first line example):

<?php // -> as categorie: { "name": "Coding", "created": "2025-08-08 12:00", "symbol": "⚙️" } ?>

Method article metadata (PHPDoc example):

/**
 * @blog {
 *   "name": "Installation",
 *   "description": "Learn how to install NanoMVC — from quick setup to shared installations. Follow clear steps for configuring your application and database.",
 *   "created": "2025-07-15 09:00"
 * }
 */
public function installation() { ... }

The plugin parses JSON-like metadata and exposes categories and articles through a simple API — great for documentation-style blogs or small sites that keep content with code.

Core Example (simplified)

To understand runtime flow, here is a short, conceptual view of the core bootstrap (excerpt):

class nmvc_core {
  public function main(): void {
    $this->path_info = $_SERVER['PATH_INFO'] ?? '/';
    include 'config_application.php';
    $this->setupErrorHandling();
    $this->setupRouting();
    $this->setupSegments();
    $this->setupController();
    $this->setupAction();
    $this->setupAutoloaders();
    $this->controller->{$this->action}();
  }
}

Requirements & License

  • PHP 8.3 or later
  • PDO extension enabled
  • License: LGPL v2.1 or later

Status

NanoMVC is actively maintained as a minimalist, modern fork of TinyMVC — preserving the original goals of simplicity while adding safe, opt-in improvements.

Author: Nipaa (fork maintainer). Original TinyMVC by Monte Ohrt.

Back to Coding