What is it?

Nanite is a micro-framework to easily handle GET and POST requests with just about any URL format you can think of.

What does it do?

  • Easily handle GET/POST requests.
  • Pretty/clean URLs
  • Regular expression URL matching
  • Contained in a single file

Show me

require 'src/Nanite.php';

// Use / for the main/index page.
Nanite::get('/', function(){
    echo "Front page";
});

// All routes start with /
Nanite::get('/about', function(){
    echo "About page";
});

// Regex enabled, groups get passed to the function.
Nanite::get('/projects/([a-zA-Z0-9\-_]+)', function($project){
    echo "Project page for {$project}";
});

// Handle a POST request
Nanite::post('/contact', function(){
    // Handle submitted contact form.
});