1. Part 1

Created Wednesday 22 January 2014

http://anantgarg.com/2009/03/13/write-your-own-php-mvc-framework-part-1/

"In simpler words-

  1. Model handles all our database logic. Using the model we connect to our database and provide an abstraction layer.
  2. Controller represents all our business logic i.e. all our ifs and else.
  3. View represents our presentation logic i.e our HTML/XML/JSON code."

"The directory structure
|-- application
| |-- controllers
| |-- models
| `-- views
|-- config
|-- db
|-- library
|-- public
| |-- css
| |-- img
| |-- js
| `-- swf
|-- scripts
`-- tmp
|-- cache
|-- logs
`-- sessions
application – application specific code
config – database/server configuration
db – database backups
library – framework code
public – application specific js/css/images
scripts – command-line utilities
tmp – temporary data"

"Coding Conventions

  1. mySQL tables will always be lowercase and plural e.g. items, cars
  2. Models will always be singular and first letter capital e.g. Item, Car
  3. Controllers will always have “Controller” appended to them. e.g. ItemsController, CarsController
  4. Views will have plural name followed by action name as the file. e.g. items/view.php, cars/buy.php"

Root directory:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>

Public folder:
<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^(.*)$ index.php?url=$1 [PT,L]

</IfModule>



Backlinks: