Skip to content

Basic Router is a very basic and small Router class builded in PHP.

Notifications You must be signed in to change notification settings

Juje/Basic-Router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Basic Router

About Basic Router

Basic Router is a very basic and small Router class builded in PHP.

Usage

1. First require the class

require 'router.class.php';

2. Add a page

$router->newPage('Hello World', 'hello-world', function(){
	echo 'Hello World!';
});

3. Than get the content

$page = $router->getContent($_GET['page'], '%title% « MyWebPage');

4. Than add the stuff the page

<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<title><?php echo $page['title'] ?></title>
</head>
<body>
	<ul>
		<?php foreach($router->getMenu('index.php', '?page=%slug%') as $url => $name): ?>
			<li><a href="<?php echo $url ?>"><?php echo $name ?></a></li>
		<?php endforeach ?>
	</ul>
	<p><?php $page['content']() ?></p>
</body>
</html>

About

Basic Router is a very basic and small Router class builded in PHP.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages