PHPackages                             4asuite/nano-php - 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. 4asuite/nano-php

ActiveProject[Framework](/categories/framework)

4asuite/nano-php
================

Ultra-minimalist PHP framework for small websites

v0.5(today)01—0%MITPHPPHP ^8.1

Since Mar 21Pushed todayCompare

[ Source](https://github.com/4asuite/nano-php)[ Packagist](https://packagist.org/packages/4asuite/nano-php)[ RSS](/packages/4asuite-nano-php/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (2)Used By (0)

Nano PHP
========

[](#nano-php)

A minimal PHP microframework. No magic, no bloat — just routing, controllers, views, and a few security essentials.

**Author:** Vlado Majoros, [4aSuite](https://4asuite.com)**License:** MIT

---

Requirements
------------

[](#requirements)

- PHP **^8.1**
- Apache with `mod_rewrite` (or equivalent front-controller setup)
- No external dependencies for the core

---

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

[](#installation)

```
composer create-project 4asuite/nano-php myproject
cd myproject
```

Point your web server document root to the `public/` directory. Open the project in a browser — the welcome page confirms the framework is running.

---

Project structure
-----------------

[](#project-structure)

```
myproject/
├── App/
│   ├── Config/
│   │   └── routes.php          # Route definitions
│   ├── Controllers/
│   │   └── NanofwController.php
│   ├── Core/                   # Framework core (do not modify)
│   │   ├── App.php
│   │   ├── Controller.php
│   │   ├── Csrf.php
│   │   ├── EnvLoader.php
│   │   ├── HttpException.php
│   │   ├── Lang.php
│   │   ├── Request.php
│   │   ├── Response.php
│   │   ├── Router.php
│   │   ├── Session.php
│   │   └── View.php
│   ├── Models/
│   │   └── Model.php           # Base PDO model
│   ├── views/
│   │   ├── layouts/
│   │   │   ├── main.php
│   │   │   └── blank.php
│   │   └── partials/
│   │       └── head.php
│   └── bootstrap.php
├── public/
│   ├── index.php               # Front controller (web root)
│   └── .htaccess
├── .env
└── .env.example

```

---

Configuration
-------------

[](#configuration)

Copy `.env.example` to `.env` and adjust as needed. Values are exposed as PHP constants.

```
APP_ENV=development
APP_DEFAULT_LANG=en

# Database (only if using Model)
DB.HOST=localhost
DB.NAME=mydb
DB.USER=root
DB.PASS=
```

Dot-notation keys (`DB.HOST`) are grouped into a single array constant `DB['HOST']`.

---

Routing
-------

[](#routing)

Define routes in `App/Config/routes.php`:

```
return [
    'GET' => [
        '/'             => [App\Controllers\HomeController::class, 'index'],
        '/users/(:num:id)' => [App\Controllers\UserController::class, 'show'],
        '/posts/(:any:slug)' => [App\Controllers\PostController::class, 'show'],
    ],
    'POST' => [
        '/users' => [App\Controllers\UserController::class, 'store'],
    ],
];
```

Route parameter types:

SyntaxMatchesExample`(:num:id)`Digits only`/users/42``(:any:slug)`Any non-slash string`/posts/hello-world`A missing route throws `HttpException(404)`, which the framework handles automatically.

---

Controllers
-----------

[](#controllers)

Extend `App\Core\Controller`. Every action must return a `Response` instance.

```
