Home >Backend Development >PHP Tutorial >Create the world's simplest PHP development model_PHP tutorial

Create the world's simplest PHP development model_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 17:30:48786browse


 php(as the current mainstream development language) As the "simplest" Web scripting language, its market in China is growing. php(as the current mainstream development language) )er is becoming more and more common, but it feels like most people have not considered the pattern issue. What kind of design pattern is optimal and most suitable for their current work? After all, efficiency is the most important (using How beautiful it is to save time playing games...). MVC should be the first choice. There are many excellent open source projects based on MVC on www.sourceforge.net. You can rush there to study them.
 
I revamped my company website a few days ago, mainly the article publishing system. My boss said that I can design the backend however I want. The only prerequisite is that it be fast. So I built a simple publishing system framework. If we look purely at the article publishing system, it can basically meet the requirements of the article publishing system for "small and medium-sized" enterprise websites. The total php (as the current mainstream development language) code in the background does not exceed 800 OK, and supports any expansion and plugin functions.
 
No more nonsense, let me talk about my structure below, I hope it will be helpful to you.
 
Note: Before starting, you need to download a template processing tool class: "smarttemplate" and understand the simple use of some templates.
 
My test environment: windows2k/apache(the most popular WEB server platform on the Unix platform)2/php(as the current mainstream development language)4.3. 2/smarttemplate class library
 
Let’s first talk about the distribution of files in the entire web site. In the following chapters, the following directories and files will be created and filled in.
The root directory of the web of my server is " C:/apache(The most popular WEB server platform on Unix platform)2/htdocs/”
I created a folder “cmstest” below as the main folder of my website
The sub-file structure under the folder "cmstest" is:
 
 /config.inc.php(as the current mainstream development language)
 /list1.php( As the current mainstream development language)
 /list2.php(As the current mainstream development language)
 /new.php(As the current mainstream development language Language)
 /add.php(as the current mainstream development language)
 /view.php(as the current mainstream development language)
 /page.js
 /src/MySQL(The best combination with PHP)Util.php(as the current mainstream development language)
 / src/ArticleUtil.php(as the current mainstream development language)
 /src/CoreUtil.php(as the current mainstream development language)
 /src/ ParseTpl.php(as the current mainstream development language)
 /src/lib/smarttemplate/*.* This directory is used to store the smarttemplate class library
/smart/template/list1 .htm
 /smart/template/list2.htm
 /smart/template/new.htm
 /smart/template/add.htm
 /smart/template/view.htm
 / smart/cache/
 /smart/temp/
 
 Design steps:
Consider the characteristics of your company’s website and the structure of the template you have designed, and summarize the functions to be implemented. , make a list.
Analyze the function list and classify the functions. Each type of function has something in common and can be implemented through the same method.
Design the table structure of the database according to the function
Design a configuration file config.inc.php (as the current mainstream development language) to record some basic information of the website, including Database name......
Design an interface function for database query for each type of function, so that similar operations in the future only need to call this interface. This avoids a large number of code duplication operations that may occur in the future, and achieves the purpose of code reuse.
Define your own packaging function for the template tool. When you call it in the future, you don’t have to worry about the use of the template tool. You only need to stuff it into your own packaging function.
The basic functions are now ok, let’s start easy page implementation and template processing.
 
We will now start to design a simple system to see how I implemented a "simplest article publishing system" step by step. Of course, it is just a simple project that I simulated. In reality, one Projects can be more complex than this.
 
 1. Analysis of my case:
 Haha, this customer project is so simple, happy...
 
list1.php(as the current mainstream development language): There are three article lists and one button, "php(as the current mainstream development language)Development article list" "php (As the current mainstream development language)Develop hot article list""ASP development latest articles""Add new article"
 list2.php(As the current mainstream development language): There are 2 article lists "ASP development article list" "ASP development hot article list"
  new.php (as the current mainstream development language) : A page with a form for adding articles
 add.php(as the current mainstream development language): Process the page of the form of new.php(as the current mainstream development language) view. php
(as the current mainstream development language): Article viewing page 

2. Analysis function“php
(as the current Mainstream development languages) Development article list" "ASP development article list" ------- Sorted in reverse order according to the publication order of the articles, with 5 articles displayed on each page "php
(do For the current mainstream development language) Development hot article list" "ASP development hot article list" ------- Display articles sorted by the number of clicks and views of the article, displaying 3 articles "ASP development latest "Article" is displayed in reverse order according to the publication order of the article, showing 3 articles
"Add new article" ------ the publishing function of an article, including article title/author/content

http://www.bkjia.com/PHPjc/509134.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/509134.htmlTechArticlephp (as the current mainstream development language) As the "simplest" Web scripting language, in the domestic market It’s getting bigger and bigger, and there are more and more PHP (as the current mainstream development language) er, but I feel...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn