@author zeyuec, 2013-02-03
This is a concise and fully functional PHP MVC framework.
- Model: Using pdo for DB connection.
- View: Smarty.
- Controller: A Simple Router Class.
All request must be redirected to this file. You can do it like this in nginx.
server {
listen 80;
server_name _;
root /home/zeyuec/www;
location ~* ^.+\.(ico|js|css|gif|jpg|jpeg|png|zip)$ {
access_log off;
expires 0d;
}
location / {
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param PATH_INFO $fastcgi_script_name;
include fastcgi_params;
}
Config file. It also includes a static function for importing Model in Controller.
Router Class which is used in index.php.
Base Controller. External libs are imported here.
Base Model. Support Yii-style (ex: TestModel::model()->doSomthing()). You need to add a function like this in every custom Model:
public static function model($className = __CLASS__) {
return parent::model($className);
}
-
Download: Download Smarty and phpmarkdown. Put them into lib/.
-
Configuration: Read core/Light.php, it's too easy to understand;
-
Format: "TestController.php", "TestModel.php" and "indexAction()" in Controller;
-
Notice: Make sure your Smarty directories are writable.
-
Run Helloworld: Run helloworld.sql then visit your website, this demo will reads data from database and write it out under markdown format.