MicroMVC
A blazing fast Model View Controller framework in less than 150kb!It offers Model, Library, Controller, Function, and View management. Plus other features like URI Routing, hooks/plugins, file uploads, database abstraction, captcha creation, and more! If you are new the Model/View/Controller world of OOP - then this system is for you. Every line is documented and it is as simple of a system to tear-apart as you can get.
MicroMVC is not a replacement for a full MCV framework. Do not plan on building the next Facebook with it! However, it does fullfil several requirements.
- Teach How MVC Works with a simple-to-understand code structure.
- Provide a base speed for comparing frameworks like Zend and CodeIgniter
- Run small scripts and systems (like blogs) that need MVC without a lot of overhead.
MicroMVC is licenced under the GPL v3 so you can use it for any personal or corporate projects free of charge.
Getting Started Video
You can watch the 20min introduction video (50MB FLV) (or 60MB windows media video) to get a quick overview of how to do things with the system. If you still need help you can post your questions in the forum on Code 2 Design.
Download
MicroMVC is hosted over at github where you can easily download the system in a zip or tar archive. You can even geek out and fork your own branch.Requirements
- PHP 5
- mod_rewrite (apache module)
- PDO if using the Database
Setup
1) Edit the system pathIf you are using MicroMVC in a subdirectory like http://localhost/MicroMVC/ then you need to change the folder settings. Open up the .htaccess file and change RewriteBase / to RewriteBase /MicroMVC. Then open the localhost folder and open sites/localhost/server.php and change the following line:
define('SITE_PATH', '/');
to
define('SITE_PATH', '/MicroMVC/');
2) Rename the "localhost" folder to whatever your site name is.
If your site is http://mysite.com then you need to rename the folder to mysite.com. If you are using a subdomain like http://mysite.somesite.com then you need to name the folder mysite.somesite.com.
3) Edit the config file.Make sure to set the values in the config file to suite you.
How the System Works
When a request is sent to the folder where MicroMVC resides, the .htaccess file will send the request to index.php. The index will load the config files in "localhost" (or whatever you name it) and then checks to see if a "cached" version of the page already exists. If not, then it will continue to load the core system files.After this, it will check with routes.php to figure out what controller and method to call.
- If a controller matching the URL is found in controllers/, then the method given (either in the URL or config) is run and the output is returned.
- If a controller is not found, then it will trigger a 404 error as the output.
The output (wither an error or not) is then placed in the current theme and the final content is sent to the users browser
One note about the theme, this system detects AJAX calls and loads ajax.php instead of layout.php when that occurs. You can override this feature from your controllers.
Extend
MicroMVC works nicely with other systems and libraries. In fact, you can download just about any class or function from any system (as long as it isn't dependent the core of that system) and MicroMVC can use it! Here are some that you might find useful:
MicroMVC © 2009 David Pennington