A super simple php Framework

Source: Internet
Author: User
: 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.

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.