
SkinnyMVC is a light-weight, easy to learn, "skinny" development framework for PHP that enables the developer to implement the MVC architectural pattern, while maintaining maximum flexibility and performance of the application.
SkinnyMVC Help
Installation
- Download SkinnyMVC
- Unzip skinnymvc.php in your project directory (for ex. /opt/myproject/)
- In your project directory, run skinnymvc install command:
> php skinnymvc.php install
SkinnyMVC will create a special directory structure under your project directory. (Click to see the SkinnyMVC default directory structure)
- Make sure that the SkinnyMVC tmp directory is writeable by the server. You can do it by running this command:
> chmod 777 tmp -R
- Now you need to add settings to your httpd.conf file:
<VirtualHost *:80>
ServerName [your domain name]
ServerAdmin [your email]
DocumentRoot [path to your project]/web
php_value include_path .:[path to your project]
<Directory "[path to your project]/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
- Last step: Restart apache (or any other web server you may be using)
Now your project is set up and you can start working. Good luck!
Command line
SkinnyMVC offers a set of commands that will help you develop your project more efficiently
> php skinnymvc.php help
Usage:
php skinnymvc.php task_name [argument]
Tasks:
install - Installs new SkinnyMVC framework
upgrade - Upgrades core SkinnyMVC files
uninstall - Uninstalls the SkinnyMVC project (deletes all files in all SkinnyMVC directories)
createModule - Creates new module (Ex.: "php skinnymvc.php createModule login")
createMod - Alias for createModule
generateSQL - Generates sql from schema.php and stores it in lib/skinnymvc/model/sql/database.sql
generateModel - Generates model classes from schema.php
help - Displays this help
Other:
* Make sure that your project's tmp directory is writable by the web server
* Your custom error pages are located in lib/skinnymvc/errors
MVC
The MVC architecture separates your project into three parts: Model, View, Controller
The Model files are located in lib/skinnymvc/model/
The View files are located in your project's modules in directories caleed templates. Each template is named after it's associated action. For example if you want to display a list of results in module "book" and you call the action "list", then the name of your template file will be list.php. This file will be located here: modules/book/templates/list.php
The Controller files are also located in your project's modules, but they are in a sub directory called "actions". Each module has one file called actions.php and each action is represented by a public method in this file. Using the same example as above, the actions file would be located in modules/book/actions/actions.php and the method associated with the "list" action would be:
public function executeList($request)
{}
Note that the name of the method starts with "execute". ALL names of methods that represent an action always start with "execute", for ex. the name of the method representing the "show" action within a module would be executeShow() and the name of the method representing the "login" action would be executeLogin(), etc.