: This article mainly introduces a super simple php Framework. if you are interested in the PHP Tutorial, you can refer to it. Recently I wrote a php Framework. the github address is as follows:
BlakeFez-PHP-Framework
This framework has few functions and is suitable for small personal websites.
The directory structure of the framework is as follows:
/Command // This directory is used to store the command class/controller // in cli mode. this directory is used to store the controller class/frame in cgi mode. // This directory is used to store the core code of the framework. blakeFez. php // This is the core file Command of the framework. php // command base class. all command classes must inherit the class CommonMysql. php // implements a mysql-type CommonRequest. php // implements a retrieve url request class. it is best to use // CommonRequest: getRequest ('option ') instead of/$ _ GET ['option'] and $ _ POST ['option'] Controller. php // the base class of the controller class. all controller classes must // inherit the Model class. php // base class of the model class, all models must inherit this class/model // This directory is used to store model classes/services // This directory is used to store public service classes/static // This directory is used to store js, css, images, etc./view // This directory is used to store front-end template files
The framework supports CGI and CLI modes.
In CGI mode, use the following method:
①. Routing method
For example, there is a url: http: // host/index. php? C = index & a = welcome
The system will actually request the welcome method of the IndexController class in the/controller directory.
② Front-end rendering
In the controller, use:
$this->out['title'] = 'welcome to china';
The variable title is output to the front-end. In the front-end template file, you can use this variable as follows:
<?phpecho$title;?>
The frontend file naming method is as follows:
For example, the front-end file corresponding to the welcome method of the IndexController class is:
/View/index/welcome. php
If the request is asynchronous and does not require frontend rendering, you can write it in the controller as follows:
$this->outType ='json';
In CGI mode, use the following method:
Php SRC_PATH/index. php-c index-a index
This line of naming will execute the index method of the IndexCommand class under the command directory.
Copyright Disclaimer: This article is an original article by the blogger. For more information, see the source.
The above introduces a super simple php framework, including some content, and hopes to be helpful to friends who are interested in PHP tutorials.