njcannington / my-mvc
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 1
Open Issues: 2
pkg:composer/njcannington/my-mvc
This package is not auto-updated.
Last update: 2026-01-11 10:43:32 UTC
README
In order to gain a better understanding of how the MVC framework operates. I wanted to build one from scratch.
Usage
Routing
Within the web/index.php file, all routing is handled with $route->add(). You just need to specify the uri, controller, and action.
eg: $route->add("/", "index", "index")
This ensures the home page is routed to the IndexController and returns the indexAction method.
Controllers
All controllers should stored in the App\Controllers namespace (and directory), using the syntax {Uppercasename}Controller (eg. IndexController). However the file itself should be all lowercase (eg. indexcontroller.php)
The action within the controller uses the syntax {lowercasename}Action (eg. indexAction)
Views
Set the view within an action using setView() method. (eg. $this->setView("/login"))). All view files are lowercase and stored in the app\views directory.
Setup
Tested with:
- PHP 5.6 - PHP 7.2
- Apache 2.4.*
- needed modules:
- mod_rewrite
- set AllowOverride to All
- point the DocumentRoot to the /web directory within project
- needed modules:
- MySQL 5.7.20