Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simplest PHP Router Ever, 1 File, Make it Your Own

NotificationsYou must be signed in to change notification settings

JREAM/route

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation


I made this in 2011, it is a no-nonsense PHP Router. Itrequires no dependencies. Fork it and have fun with it.

This is a class with two methods! I figured I'd port this over frommy old repositories. There are a thousand routers, all and everythingbuilt into frameworks -- sometimes it's fun to go back to the basics.

This project was Inspired byKlein

Requirements

You needPHP 5.3 or higher.

How to use

You only need two files:

  • 1:route.php
  • 2:.htaccess

The.htaccess redirects all requests toindex.php?uri=$.

You can run everything from the index.php file, see the file for usage.

Examples

Require the route.php file and create an instance.

require_once'route.php';$route =newRoute();

Here is how you'd add your home page.

$route->add('/',function() {echo'This is the home page, there is no template engine';});

Here is how to add arguments

$route->add('/name/.+/age/.+',function($name,$age) {echo"Your name is$name and you are$age years old";});

After all routes are defined, you always end it with:

$route->listen();

Copyright (C), 2012 Jesse Boyer (http://jream.com)GNU General Public License 3 (http://www.gnu.org/licenses/)

About

Simplest PHP Router Ever, 1 File, Make it Your Own

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp