PHPackages                             paigejulianne/nanomvc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. paigejulianne/nanomvc

ActiveLibrary[Framework](/categories/framework)

paigejulianne/nanomvc
=====================

NanoMVC: a lightweight MVC framework with Blade, Smarty, and Twig template support

1.0.1(4mo ago)02GPL-3.0-or-laterPHPPHP &gt;=8.0

Since Jan 4Pushed 4mo agoCompare

[ Source](https://github.com/paigejulianne/nanomvc)[ Packagist](https://packagist.org/packages/paigejulianne/nanomvc)[ Docs](https://github.com/paigejulianne/nanomvc)[ RSS](/packages/paigejulianne-nanomvc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

NanoMVC
=======

[](#nanomvc)

A lightweight MVC framework for PHP 8.0+ with support for Blade, Smarty, and Twig templates.

**Version 1.0.1** | [Changelog](CHANGELOG.md) | [License: GPL-3.0](LICENSE)

by Paige Julianne Sullivan [paigejulianne.com](https://paigejulianne.com) | [GitHub](https://github.com/paigejulianne/nanomvc)

---

Features
--------

[](#features)

- **Enterprise-scale performance**: O(1) route lookup, route caching, middleware caching
- **Multiple template engines**: PHP, Blade, Smarty, and Twig support
- **Simple routing**: Clean URL routing with parameters and groups
- **Zero dependencies**: Only requires PHP 8.0+ (template engines optional)
- **Built-in validation**: Request validation with helpful error messages
- **Session management**: Secure sessions with CSRF protection
- **Rate limiting**: Configurable throttling for API endpoints
- **Response compression**: Automatic gzip compression
- **Integrates with NanoORM**: Seamlessly works with [NanoORM](https://github.com/paigejulianne/nanoorm) for database operations

---

Prerequisites
-------------

[](#prerequisites)

- **PHP 8.0+** with the following extensions:
    - `json` (usually enabled by default)
    - `mbstring` (recommended)
- **Apache** with `mod_rewrite` enabled, or **Nginx**
- **Composer** (for installation and autoloading)

---

Installation
------------

[](#installation)

### Via Composer (Recommended)

[](#via-composer-recommended)

```
composer require paigejulianne/nanomvc
```

### Manual Installation

[](#manual-installation)

Download `NanoMVC.php` and include it in your project:

```
require_once 'NanoMVC.php';
```

---

Examples
--------

[](#examples)

NanoMVC includes four example applications demonstrating each template engine:

ExampleTemplate EngineDirectoryPHP (Native)Native PHP`example/`BladeLaravel Blade`example-blade/`SmartySmarty`example-smarty/`TwigTwig`example-twig/`### Running the Examples

[](#running-the-examples)

1. **Install dependencies:**

    ```
    composer install
    ```
2. **For Blade example, also install:**

    ```
    composer require jenssegers/blade
    ```
3. **For Smarty example, also install:**

    ```
    composer require smarty/smarty
    ```
4. **For Twig example, also install:**

    ```
    composer require twig/twig
    ```
5. **Set file permissions:**

    ```
    chmod 644 example*/.htaccess
    chmod 755 example*/cache
    ```
6. **Access in your browser:**

    - PHP: `http://localhost/path/to/nanomvc/example/`
    - Blade: `http://localhost/path/to/nanomvc/example-blade/`
    - Smarty: `http://localhost/path/to/nanomvc/example-smarty/`
    - Twig: `http://localhost/path/to/nanomvc/example-twig/`

> **Note:** Ensure Apache `mod_rewrite` is enabled and `AllowOverride All` is set for your directory. See [Apache Configuration](#apache-configuration) for details.

---

Quick Start
-----------

[](#quick-start)

### 1. Create Your Entry Point

[](#1-create-your-entry-point)

Create `index.php`:

```
