Skymvc framework of Skynet plan

Source: Internet
Author: User

Introduction: This is a detailed page of skymvc framework of Skynet. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339493 'rolling = 'no'>

Skymvc is a lightweight and simple PHP
The MVC Framework draws on the design of various major frameworks and uses many excellent functions and classes. skymvc does not encourage silly development and focuses more on giving developers more room for thinking. The framework is mainly used to implement multipleProgramCollaborative Development between members and Implementation of the MVC development mode. skymvc adopts the MVC development mode, and the framework itself is easy to expand. As the basic framework of skymvc's Skynet program, adhering to the excellent tradition of easy to use, easy to learn, and joint development, we are committed to creating an excellent PHP
MVC framework. You are welcome to give more suggestions.
1. Create the configuration file skymvc to automatically create the website directory: Enter http: // locahost/skymvc/install. php to automatically create
File directory. If you want to create a new one, delete the install. Lock file.
Automatic creation is recommended.
You can also manually create: directories can be customized.
Configure the program when creating a custom directory
Admin background directory
Admin/Model
Admin/CTRL
Attach
Uploaded attachment directory
CTRL control file directory
Data Directory
Data/config. php
Configuration File
Data/cache directory
Data/Cache/CSS
CSS Cache
Data/Cache/file File Cache
Data/Cache/TPL template Cache
Data/Cache/JS
JS Cache
Model file directory
TPL template directory
TPL/admin background Template
TPL/Default
Default Template
JS directory
Plug-in Directory
Admin. php background portal File
Index. php front-end entry file
2. Entry File

Skymvc adopts a single portal mode, but it is not the only portal. Two portals are recommended. One is the frontend portal and the other is the background portal.
1. Front-end portal file instance: index. php file name can be customized to recommend index or
Default
<? PHP
Require
"Data/config. php"; // load the configuration file
Require ("skymvc/skymvc. php"); // reference the framework File
// Determine whether the controller is valid
$ _ Get ['M'] = isset ($ _ Get ['M'])
&&
In_array ($ _ Get ['M'], array ('index '))? $ _ Get ['M']: 'index ';
// Judge the end
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 termination
$ Method = isset ($ _ Get ['a'])
& Method_exists ($ control, 'on'. $ _ Get ['a'])?
'On'. $ _ Get ['a']: "ondefault ";
$ Control-> $ method ();

?
2. the admin. php file name can be customized.
<? 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 ()
?>
Note: there is little difference between the front and back-end entry files, mainly in the folder where the model and control files are located.
3. Controller File
<? PHP
Class indexcontrol extends skymvc
{
Function
_ Construct ()
{
$ This-> indexcontrol ();
}

Function
Indexcontrol ()
{
Parent: :__ construct (); // initialize the parent class
$ This-> loadmodel ("Index ");
// Background

// $ This-> loadadminmodel ("Index ");
}
Function
Ondefault ()
{

$ This-> TPL-> assign ("welcome", "Welcome to skymvc. Let's work together! ");
$ This-> TPL-> assign ("who", $ _ env ['indexmodel']-> test ());
// Background
// $ This-> TPL-> assign ("who", $ _ env ['admin _ indexmodel']-> test ());
$ This-> TPL-> display ("Index ");
}
?>

4. model file
the model file is mainly used to process data. Of course, it can also process other logic, but is not recommended. File naming rules: class. model. php
for example, index. model. PHP.
the model file is located under the model directory, for example, the model directory
example: Index. model. php
class
indexmodel
{< br> Public $ base;
function
__ construct (& $ Base)
{< br> $ this-> indexmodel ($ base);
}< br> function
indexmodel (& $ Base)
{< br> $ this-> base = $ base;
$ this-> DB = $ base-> dB;
}< br> function
test ()
{< br> echo "this is a model test";
}

}< BR >?>
model file: the front and back ends are stored in different places
5. Hello World
Hello word of kymvc framework!
If the directory is automatically created.
Configure the database
index. php
.
index. php content
require
"Data/config. PHP "; // load the configuration file
require (" skymvc/skymvc. PHP "); // reference the framework file
// determine whether the controller is legal
$ _ Get ['M'] = isset ($ _ Get ['M'])
&
in_array ($ _ Get ['M'], array ('index', 'Article '))? $ _ Get ['M']: 'index'; // you can specify all. all modules appearing in the PHP entry are placed in array ()
// judge the end
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 the
hello. CTRL. php file in the CTRL directory
class
hellocontrol extends skymvc
{

function _ construct ()
{< br> $ this-> hellocontrol ();
}< br> function
hellocontrol ()
{< br> parent ::__ construct ();
$ this-> loadmodel ("hello "); // Load Model
Any model can be loaded but cannot be a model of the same class
}< br> // name of the action executed by default on function name
Function
ondefault ()
{< br> echo "Hello World
"; $ this-> smarty-> display ("hello.html ");
}< br> // when M = Hello, A = test
executes the following function
ontest () {
$ this -> TPL-> assign ("test", $ _ env ['hellomodel']-> gettest ());
$ this-> TPL-> display ("hello.html");

}< BR >}?>
under the model directory
Create hello. model. php
class hellomodel
{< br> Public
$ base;
function
__ construct (& $ Base)
{< br> $ this-> hellomodel ($ base);
}

Function
Hellomodel (& $ Base)
{
$ This-> base = $ base;
$ This-> DB = $ base-> $ dB;
}
// You do not need to modify the above
Function gettest (){
Return $ this-> DB-> getrow ("select * from test
Limit 1 "); // read data
}
}
?>
Create hello.html In the TPL directory
<! Doctype html
Public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type"
Content = "text/html; charset = gb2312"
/>
<Title> untitled document </title>
</Head>

<Body>
This is the first example: Hello world!
This is a test example: {loop $ test $ t} {$ t}
{/Loop}
</Body>
</Html>
Official: http://www.sky-plan.net download: skymvc1.0 official http://down.chinaz.com/soft/30023.htm

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/339493.html pageno: 8.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.