No hidden conventions, no auto-wiring. Every line of code is exactly where you put it.
Zero external packages in the core. PHP 8.1+ and a web server — nothing else required.
The framework provides structure. You write the logic. No opinions on your architecture.
What's inside
Router | GET/POST with named parameters. Pattern matching via (:num:id) and (:any:slug). |
Controller | Base class with view(), json(), and redirect() helpers. |
Request | Wraps input with get(), post(), input(), method(). |
Response | Fluent API for HTML, JSON, redirect, and security headers. |
Session | Secure session with httponly, samesite=Lax, strict mode. |
CSRF | 64-char hex token, stored in session, rotated on each verification. |
View + Layout | PHP templates with layout system and e() escape helper. |
EnvLoader | Loads .env as PHP constants. Dot-notation: DB.HOST → DB['HOST']. |
Get started
composer create-project 4asuite/nano-php myproject cd myproject php -S localhost:8000 -t public
// App/Config/routes.php
return [
'GET' => [
'/' => [HomeController::class, 'index'],
'/about' => [HomeController::class, 'about'],
],
];
class HomeController extends Controller
{
public function index(): Response
{
return $this->view('home', [
'title' => 'Home'
]);
}
}
<!-- App/views/home.php --> <h1><?= e($title) ?></h1> <p>Welcome to Nano PHP.</p>
Compatibility