GithubHelp home page GithubHelp logo

criticalbh / php-simple-routing-system Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 6.0 5 KB

This little script provides you a way to have pretty URLs in your php web site. If you just want to have routes but you do not want to bother with massive php frameworks, you could find this useful

PHP 100.00%

php-simple-routing-system's Introduction

Simple Routing System

Have you ever wished to have routes in your php website but you do not want to install all those massive frameworks? This is solution for you.

Installation

Pull files from repository and place them in your htdocs

Config

Open core/config.php

    home      =>      Your index page
    pages     =>      Directory with your pages.
    handler   =>      Page that will be shown when url is wrong

Routes

Open routes.php to add new routes

Router::add('URL', 'PAGE', 'ROUTE-NAME [opt]');

Router::add('home', 'home.php');
Navigating to yourwebsite.sth/home will load home.php

Examples

Router::add('home', 'home.php', 'home');
Router::add('home', 'home.php');
Router::add('lives/home/', 'live.php', 'lives');

Call route by name

 <a href="<?php Router::name('home'); ?>">Home</a>
 or just by URL specified
 <li><a href="home">Lives</a></li>

php-simple-routing-system's People

Contributors

criticalbh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

php-simple-routing-system's Issues

Routing issue

I was not able to get this to work straight from the zip file. I had kept getting the default error handler message when clicking on the 'Home' link. Looking further into the issue, I found that in engine.php on line 32 you have if($url == $route['link']), my $url kept coming back with /home/ and the $route['link'] was coming back as home.

I modified this in my version to:
if(str_replace('/', '', $url) == $route['link']){

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.