Giter Club home page Giter Club logo

route's Introduction

Route


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

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

This project was Inspired by Klein

Requirements

You need PHP 5.3 or higher.

How to use

You only need two files:

  • 1: route.php
  • 2: .htaccess

The .htaccess redirects all requests to index.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 = new Route();

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/)

route's People

Contributors

jream avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.