The framework is mainly used to realize the collaborative development between multiple programmers and the implementation of MVC development pattern. SKYMVC uses MVC development approach, the framework itself is easy to expand. SKYMVC as the basic framework of Skynet project, adhering to the fine tradition of ease of use, easy learning and common development, we are committed to creating an excellent PHP
MVC Framework. You are welcome to make some suggestions.
1. Create a profile SKYMVC supports the automatic creation of a Web site directory: Input http://locahost/skymvc/install.php can be created automatically
File directory. If you want to recreate it after you create it, delete the Install.lock file and the available.
Automatic creation is recommended.
You can also create them manually: Catalogs can be customized
Customizing the directory requires the appropriate configuration of the program
Admin Background Directory
Admin/model
Admin/ctrl
Attach
Uploaded attachments Directory
Ctrl Control File directory
Data Directory
data/config.php
Configuration file
Data/cache Cache Directory
Data/cache/css
CSS Caching
Data/cache/file File Cache
DATA/CACHE/TPL Template Caching
Data/cache/js
JS Cache
Model file Directory
TPL Template Directory
Tpl/admin background Template
Tpl/default
Default templates
JS Directory
Plugin Plugin Directory
admin.php Background Entry file
index.php Front Entrance file
2. Entry file
SKYMVC uses a single entry mode, but is not the only portal, it is recommended to use two entrances. One is the front entrance, the other is the backstage entrance.
1. Foreground entry File instance: index.php filename can be customized to recommend index or
Default
Copy Code code as follows:
<?php
Require
"data/config.php";//Load configuration file
Require ("skymvc/skymvc.php");//Referencing frame file
Determine if the controller is legitimate
$_get[' m ']=isset ($_get[' m '))
&&
In_array ($_get[' m '],array (' index '))? $_get[' m ': ' Index ';
End of Judgment
Require_once (Ctrl_dir.) /{$_get[' m ']}.ctrl.php ");
$classname
= $_get[' m ']. ' Control ';
$control = new
$classname ();
Configure Pseudo-static
$control->tpl->rewrite=false;
$control->tpl->rewrite_rule=array (Array ("/index.php/i"), Array ("index.html"));
Configure pseudo static End
$method =isset ($_get[' a '])
&& method_exists ($control, ' on '. $_get[' a '])?
' On '. $_get[' A ']: "Ondefault";
$control-> $method ();
?>
2. Background entry file: admin.php file name can be customized
Copy Code code as follows:
<?php
Require
"Data/config.php";
Require ("skymvc/skymvc.php");
$_get[' m ']=isset ($_get[' m '))
&&
In_array ($_get[' m '],array (' index ', ' article '))? $_get[' m ': ' Index ';
Require_once (Admin_dir.) /". Ctrl_dir. " /{$_get[' m ']}.ctrl.php ");
$classname
= $_get[' m ']. ' Control ';
$control = new
$classname ();
Configure Pseudo-static
$control->tpl->tplid= "admin";
$control->tpl->currdir= "admin";
$control->tpl->rewrite_on=true;
$control->tpl->rewrite_rule=array (Array ("/index.php/", "index.html"));
$method =isset ($_get[' a '])
&& method_exists ($control, ' on '. $_get[' a '])?
' On '. $_get[' A ']: "Ondefault";
$control-> $method ()
?>
Description: Before the background entry file is not very different, mainly in the model and Control files folder.
3. controller file
Copy Code code as follows:
<?php
Class Indexcontrol extends Skymvc
{
function
__construct ()
{
$this->indexcontrol ();
}
function
Indexcontrol ()
{
Parent::__construct ();//Parent class initialization
$this->loadmodel ("index");
Background
$this->loadadminmodel ("index");
}
function
Ondefault ()
{
$this->tpl->assign ("Welcome", "Welcome to use SKYMVC, let us work together!" ");
$this->tpl->assign ("Who", $_env[' Indexmodel ']->test ());
Background
$this->tpl->assign ("Who", $_env[' Admin_indexmodel ']->test ());
$this->tpl->display ("index");
}
?>
4. Model files
Model files are primarily used to process data, and of course other logic can be handled, but not recommended. File naming specification: class. model.php
such as: index.model.php.
Model files are located under the Model directory: such as model directory
Example: index.model.php
Copy Code code as follows:
<?php
Class
Indexmodel
{
Public $base;
function
__construct (& $base)
{
$this->indexmodel ($base);
}
function
Indexmodel (& $base)
{
$this->base= $base;
$this->db= $base->db;
}
function
Test ()
{
echo "This is model test";
}
}
?>
Model files: The same place is stored in the same background as before
5.hello World
Kymvc frame of Hello Word!
If the directory is created automatically.
Configure the database.
index.php
The entry file is well written.
index.php content
Copy Code code as follows:
<?php
Require
"data/config.php";//Load configuration file
Require ("skymvc/skymvc.php");//Referencing frame file
Determine if the controller is legitimate
$_get[' m ']=isset ($_get[' m '))
&&
In_array ($_get[' m '],array (' index ', ' article '))? $_get[' m ': ' index '; Insert all modules that appear in the index.php entry into array ()
End of Judgment
Require_once (Ctrl_dir.) /{$_get[' m ']}.ctrl.php ");
$classname
= $_get[' m ']. ' Control ';
$control = new
$classname ();
$method =isset ($_get[' a ']) &&
Method_exists ($control, ' on '. $_get[' a '])?
' On '. $_get[' A ']: "Ondefault";
$control-> $method ();? >
Create in Ctrl directory
hello.ctrl.php file
Copy Code code as follows:
<?php//hellcontrol class naming code class name control
Class
HelloControl extends Skymvc
{
function __construct ()
{
$this->hellocontrol ();
}
function
HelloControl ()
{
Parent::__construct ();
$this->loadmodel ("Hello");/load Model
Models that can load any model but cannot be the same class
}
The name of the action naming specification on function that is executed by default
function
Ondefault ()
{
echo "Hello World"
"; $this->smarty->display ("hello.html");
}
When M=hello, A=test
Perform the following function
function
OnTest () {
$this->tpl->assign ("Test", $_env[' Hellomodel ']->gettest ());
$this->tpl->display ("hello.html");
}
}?>
Under the Model directory
Create hello.model.php
Copy Code code as follows:
<?php
Class Hellomodel
{
Public
$base;
function
__construct (& $base)
{
$this->hellomodel ($base);
}
function
Hellomodel (& $base)
{
$this->base= $base;
$this->db= $base-> $db;
}
There's no need to change it.
function Gettest () {
return $this->db->getrow ("SELECT * FROM Test"
Limit 1 ");//Read data
}
}
?>
New hello.html under the TPL directory
Copy Code code as follows:
<! DOCTYPE html
Public "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
<meta http-equiv= "Content-type"
Content= "text/html; charset=gb2312 "
/>
<title> Untitled Document </title>
<body>
This is the first example: Hello world!
This is an example of the test: {loop $test $t} {$t}
{/loop}
</body>
SKYMVC Download Address