PHP Nano Framework (WIP)

IvanBernat

Ivan

3 years ago · 299 views
function Route($route, $action) {
	$route = '/^' . str_replace('/','\/',$route) . '$/';
	if (preg_match($route, $_GET['url'])) {
		$action();
	}
}

Route('page/(\d+)', function() {
	echo "Hello";
});;
Raw

Just throwing some ideas out of my head. All you need is a .htaccess with

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

Basically, I'm working on a one file framework to build micro apps very fast

Tagged: php
Comments are only visible to Forrst members. Log in or Request an invite.
3 new notifications