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 Reference

Controller

The Controller is located in lib/skinnymvc/controller

Database Control Classes

Database Control Classes are located in lib/skinnymvc/dbcontroller

Core Classes

Core SkinnyMVC files are located in lib/skinnymvc/core/

The core classes are:

  • SkinnyActions
    The parent class for all actions.
  • SkinnyBaseModel
    This is the base class for all Model classes.
    • SkinnyModel
      This class lays between the SkinnyBaseModel and the Model (database) classes
      Use this class for methods you want to extend to all Model classes.
  • SkinnyException
    The SkinnyException class. Extend all your exception classes from this one.
  • SkinnyDbException
    The Skinny Database Exceptionclass. Extend all your DB exception classes from this one.
  • SkinnyUser
    The session persistence class.


Database Schema

Your database schema file is located in config/schema.php .

This file is used to generate the Model:

> php skinnymvc.php generateModel

It is also used to generate the sql:

> php skinnymvc.php generateSQL

The database schema is a regular PHP array. It should be structured like the example below:

<?php
  $model = array('table1'=>array(
                                  'field1'=>array('type'=>'int', 'null'=>false, 'special'=>'auto_increment'),
                                  'field2'=>'datetime',
                                  'field3'=>'varchar(255)',
                                  '_INDEXES'=>array('field3'),
                                  '_PRIMARY_KEY'=>array('field1'),
                                  '_DATABASE_KEY' => 'db1',
                                ),
                 'table2'=>array(
                                  'field1'=>array('type'=>'int', 'null'=>false, 'special'=>'auto_increment'), //null is false by default
                                  'field2'=>'decimal(10,4)',
                                  'field3'=>'varchar(255)',
                                  '_INDEXES'=>array('field3'),
                                  '_PRIMARY_KEY'=>array('field1'),
                                  '_DATABASE_KEY' => 'db1',
                                ),
                 'table3'=>array(
                                  'field1'=>array('type'=>'int', 'null'=>false, 'special'=>'auto_increment'),
                                  'field2'=>array('type'=>'varchar(255)', 'null'=>false),
                                  'field3'=>'text',
                                  'field4'=>'int',
                                  'field5'=>'int',
                                  '_UNIQUES'=>array('field2'),
                                  '_FULLTEXT'=>array('field3'),
                                  '_PRIMARY_KEY'=>array('field1'),
                                  '_FOREIGN_KEY'=>array('field4'=>array('table'=>'table1','field'=>'field1'), 'field5'=>array('table'=>'table2','field'=>'field1')),
                                  '_DATABASE_KEY' => 'db1',
                                ),
                   );
 
?>
    

Now, you need to define the '_DATABASE_KEY' in config/settings.php

<?php
     // Various settings here
     // ...
     // ...

     // Database settings
     "dbs" => array(
                   "db1"=> array(
                                       "dbdriver"   => "pgsql",
                                       "dbname"     => "usr",
                                       "dbhost"     => "127.0.0.1",
                                       "dbport"     => "5432",
                                       "dbuser"     => "usr1",
                                       "dbpassword" => "password",
                                      ),
                   "db2"=> array(
                                       "dbdriver"   => "mysql",
                                       "dbname"     => "myusr",
                                       "dbhost"     => "127.0.0.1",
                                       "dbuser"     => "myusr1",
                                       "dbpassword" => "password",
                                      ),
             ),

 


     // More settings
     // ...
     // ...
    ?>
    

Powered by SkinnyMVC       |       SkinnyMVC License       |       Developed by Radoslav Gazo and Charles Iliya Krempeaux