git clone https://github.com/flouthoc/orc.git
Simply clone the latest Orc from github repository
By default system supports php handle for mysqli but every possible database system can be added to Orc by creating a OO handle for respective Database system in ../application/db.class.php, it would be great if you'll put handle for your DB engine here.
http://domain.com/controller.php?rt=action/there/goes/arguments/
http://domain.com/controller/action/there/goes/arguments/
Major Part of the framework will be constructed of controllers and custom controllers.Controllers are something which are responsible for taking response from User and processing them accordingly to give Model appropriate data to process the Bussiness Logic from there the Data is retrived by Views and that's how the cycle rolls.
Controllers calls the Model by using some of the methods , we are going to call them actions. Each Controller have many actions to proceed giving arguments to be processed by Model.So we can assume action like this.
/**This is not how i'll look in code , this is just to give you rough image **/
$controllerInstance->action($argumentarray);
/** similarly action() makes a call to model **/
Class indexController Extends baseController {
public function index() {
/*** set a template variable ***/
$this->registry->template->welcome = $this->model->welcome;
/*** load the index template and get file from VIEW ***/
$this->registry->template->show('index');
}
/* A test function to check weather we can recieve arguments via url or not */
public function poop($array){
var_dump($array);
}
public function some_random_action_which_calls_model($argumentarray){
/** Do some random operation on welcome by taking argument **/
$this->model->somemethod($argumentarray);
$this->registry->template->welcome = $this->model->welcome;
/*** load the index template and get file from VIEW ***/
$this->registry->template->show('index');
}
}
Views are basically a HTML skeleton , or HTML layout which can contain PHP based template variables to load dynamic content inside these variables and these variables must be attribute of instance of template class which is to be stored in $registry (object of registry class) and these Template Variables can be manipulated in any action of the respective controller of View.
<html> <head> </head> <body> <h1><?php echo $welcome; ?></h1> <p><?php echo $blogContent ?></p> </body> </html>
Using Template Variables with custom ControllersClass indexController Extends baseController { public function index() { /*** setting template variables a template variables ***/ $this->registry->template->welcome = "Welcome User"; $this->registry->template->blogContent = "Here goes your blog content"; /*** load the index template or name of view ***/ $this->registry->template->show('index'); } }
Models are something which contain Business Logic and it is to be noted that every can only be called from controller of that model. Model can contain many methods and these methods can take argument from Controller methods and can update the template variables further. Every model must be stored in ../model/ with name convention like this 'name'Model.class.php
class indexModel{
public $welcome = "Welcome to blog";
public $blogContent;
public getBlogContent(){
$this->blogContent = make_database_call();
}
}
Inside ../application/ there is a class named db.class.php you can use object of this class to get the mysqli handle you can use it like this.
$dbinstance = new db("mysql","host","user","passwd","database");
/*Now you can use $handle attribute of this object to call mysqli method*/
$dbinstance->handle->query("SELECT * FROM foo");
/*you can also store this inside registry so that you can get this upto MODEL*/
$registry->db = $dbinstance;