Introduction
This is designed to be simple and straight forward coding in MVC pattern. It doesn't require you to study loads of documentation. This framework will allow you to start coding immediately.Lightweight? It will even float in the air! This is as simple as coding pure PHP.
A very simple MVC programming pattern implementation on PHP
If you don't want to spend hours studying bloated PHP framework and create a site immediately with MVC pattern, this is the right template for you. This is not even a framework but just a simple PHP code that will get you going!
Details
Requirements- PHP5
- Knowledgeable on MVC pattern
- Subversion (used to checkout the files) http://tortoisesvn.net/downloads.html
- Download Right Click And Click "Save link As.."
- Remove all the sample codes if you don't need it.
- Project https://code.google.com/p/php-simplemvc/
- Wiki https://code.google.com/p/php-simplemvc/wiki/PHPSimpleMVC
1. To create a controller just inherit Controller class.
2. To invoke controller methods there should be a Post key with postfix "_action" or "action" (not a postfix) . The value of that key will be the name of the method to be executed. example
<input type="text" name="data" id="data" value="1"> <input type="submit" name="submit_action" id="submit_action" value="MethodName"> . . . class MyController extends Controller { public MethodName ($data) {} }
3. Parameters of the controller method should be the same name with the post data.
<input type="text" name="data" id="data" value="1"> . . public MethodName ($data) {}
4. Call Controller method PopulateRequest? to where you want to post your data. If you post within the same page, use it to display a view and expent a returned data, then put it there. Sample Here . If you post it to the controller page, you don't expect any return data, then put the PopulateRequest? to the controller page.Sample Here .
$controller1 = new Sample2Controller(); . . $controller1->PopulateRequest ();
5. You should put the files accordingly (View, Model and Controller) and code using the MVC way. And I know your awesome!
6. This is not a pure MVC so get over it! And if you want to improve it email me at diola90@gmail.com
Authored by: Jose Levi J. Diola
No comments:
Post a Comment