Giter VIP home page Giter VIP logo

simple_php_router_and_autoloader's Introduction

simple php router and autoloader

About as simple as it gets and still be useful

how does it work

autoloader.php scans all files/folders within /classes (or your choice of folder) for required classes, loads them, and executes a method called init().

router.php translates the route in a browser to a php class and executes the init() method in that class.

requirements

php 7.x

installation

  • copy files to a directory of your choice
  • open the directory with a terminal/console/cli
  • start with php -S localhost:4567
  • use a browser to navigate to localhost:4567
  • try the routes in lines 14 - 16 of router.php:
    • localhost:4567
    • localhost:4567/about
    • localhost:4567/enrol

structure

Looks like this:

-------------------------------------------------------------------------------
 Language            Files        Lines         Code     Comments       Blanks
-------------------------------------------------------------------------------
 HTML                    3           40           30            0           10
 Markdown                1           54           54            0            0
 PHP                     9          226          120           77           29
-------------------------------------------------------------------------------
 Total                  13          320          204           77           39
.
├── classes
│   ├── autoloader.php
│   ├── pages
│   │   ├── getabout.php
│   │   ├── gethome.php
│   │   ├── getregister.php
│   │   └── getthanks.php
│   └── router.php
├── frontend
│   ├── about.html
│   ├── fourohfour.html
│   ├── index.html
│   ├── register.php
│   └── thanks.php
├── index.php
└── README.md

Help yourself to the code, and if it's of any use then a star would be nice (top right...)

simple_php_router_and_autoloader's People

Contributors

petercz1 avatar

Watchers

 avatar  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.