A Simple Router in PHP using MVC pattern
Simon Trichereau
website
To get the version with the 404page, switch your branch to : version404
git checkout version404
- Install the project
- Modify
assets/php/functions/routes.php
to add all your routes from your Site :$route->add('URL','MODEL');
$route->add('URL:PARAMETER','MODEL');
- Add a Model (REQUIRED), a Controller and a View
assets/php/elements/models/
,assets/php/elements/controllers/
andassets/php/elements/views/
for each Route you've created - The routes return the link to the Model, which include controller and view to the page
- The variables you would use
$pageTitle
- Give a title to the page (Use it in Model or Controller)$paramUrl
- Use a parameter of the URl if exists (Example the ID, the name...)$phpPath
- If you want to modify the PATH of the php files
In your Command Line Editor, use : git clone https://github.com/trenyture/Router.git
Click on Clone or Download button then on Download ZIP
| - .htaccess
| - index.php
| - README.md
| ---- assets
| ---- css
| - main.css
| ---- php
| ---- functions
| - router.php
| - routes.php
| ---- elements
| - header.php
| - footer.php
| ---- models
| - home.php
| - post.php
| - posts.php
| ---- controllers
| - home.php
| - post.php
| - posts.php
| ---- views
| - home.php
| - post.php
| - posts.php
© Simon Trichereau - 2016
This project is totally free for commercial or personnal use and modifications are welcome!
To contact me you can send me a message to : [email protected]