Without WordPress and other ready-made things, want to write their own, mainly want to consolidate the summer during the reading of PHP basic knowledge.
First of all, it must be a data table, generally speaking, the general number of tables? Administrator Information sheet, post table, comment form, article classification table .... Here I do not know which tables to build, I see a lot of blogs will also have some article tags, articles archive, browse the list, popular comments and other things.
Refer to a number of tutorials, the whole blog with the MVC approach, this is generally known, did not use the framework of the thinkphp, I do not know if there is no professional can roughly say a specific structure.
Reply content:
If you're just practiced hand. Suggestions:
1. Go to GitHub and find a good project read the source code
2. Find a good tutorial on the practice database is the basis of all data, according to your own needs to design
First of all, you need to start with the product design, first think about you this program will be related to what functional points (background management? Multi-user coexistence? Multi-layer classification? Single article multi-classification? Label? Article title map? Photo Album system? )。
For example, you need a multi-user system, you need to member table, if you need background management, there are two options, a separate Administrtor table or administrator also exists member table, the latter, you can create a Member_type table to define the user type. The primary is the problem, the design of the database can meet the needs of your product. Further, the user can customize the field, which requires a member_custom table and the like, in the form of Key->value to store user-defined properties.
At the beginning of a clumsy design, it is important to understand the database of such a relatively rigid data storage format limitations, when you have the need to change the time may have to do more work to meet the changes. The so-called experience is that when you do this kind of work later, you know the length of the design (more flexible design means that the program needs more and more ingenious code), and make the appropriate trade-offs. I really found a question to be answered.
First of all, I think, just get started, or don't take other people's change, you may not read.
This semester has a software class, and then our group I decided to write a blog, I understand knowledge: The MVC framework Basic process (not an MVC framework OH), PHP basic knowledge, database operations, html+css part of the knowledge.
OK, so I started, although a group, but I was a person to complete.
Write the frame first:
index.php entry file: path constant, auto load, distribution parameters.
Framework files: Contains database operations, factory pattern Generation singleton model, base controller, base model class.
Application Files: Platform folder: Model,view,controller.
A blog, to be divided into the foreground and backstage.
Front desk is mainly visitors to see, is: Home, article sharing, note sharing, self-introduction, message board, search box, article Archive, tab bar and other functions. (The core is MySQL query, plus filter display, plus front-end typesetting, SQL injection, etc.)
Backstage is the administrator operation: Login, Control session, the crud of the article, CRUD notes, message board crud, exit and other functions. (core of the background, operation database, filtering data, escaping data, injecting etc.)
Backstage the most important, you see other people's blog, the article is a picture of it, but the simple use of areatext is impossible to do, Baidu a bit, not Google: Rich Text editor. Then there are a lot of free rich Text editor, download a good point, have the document has the description, follow, and then insert the data remember to filter, but you in the foreground display, not to display the title and part of the content, do the filtering: May use strip_tags,mb_substr and so on.
Then the basic blog will come out, but the loophole should be more than the number of countless, how to do it, continue to learn the main problem, together refueling! Database design
1 User table: User number, login name, password, display name, user category number (0: Normal user, 1: administrator), other
2 Article Classification table: Classification number, category name, parent category number (0: root classification (can achieve infinite level)), sort, other (if shown)
3 Article table: article number, title, summary chart, summary content, content, publication time, statistics (browse, comment, etc.), post (user number), article category (category number), keywords (, word one, word two, word three,), sort, top, recommended, other (if shown, whether to allow comments, etc.)
4 Navigation Table: Navigation number, navigation display name (such as: I love PHP), navigation address (such as: PHP, if the PHP framework can be used to achieve user access http://www. test.com/php
, the program automatically reads this navigation corresponding article classification of data), article classification (classification number)
5 Reviews Table: Comment Number, comment content, publication time, affiliation article number, parent comment number (can achieve unlimited level of comment), post number
6 File Table: File number, file storage address (generally absolute root directory such as:/file/img/1.jpg), file size, file type (0: Picture, 1: file (generally only download txt,rar,zip ... ), 2:video .... ), Publication number
7 Site basic Information table: Browser Title,keyword, etc...
Approximate program structure
1 Common parts: User login, user exit, user personal page, user upload file management, etc.
2 Background section (only administrators can enter): All of the above database tables increase, delete, change, check
3 Front-Desk section: Write the article List and the article detail page by all available navigation, the article detailed comments and add comments, may also appear the ordinary User personal center (easy to see what articles they read, in which articles commented)
Frame selection
I learned TP, but I use CI, because I think CI is very simple, CI's manual is very good
Difficulties that may be involved
Editor, now mostly with Baidu Ueditor, but I still use is Kindeditor
The difficulty is that these editors themselves do not own the user file management (such as the user to comment on the editor to choose to insert the picture, you can select the previously uploaded pictures), you have to change the original editor code, to achieve this function Xie invited, you say do not want to use WordPress, I want to write, consolidate the basic knowledge.
Don't you know that rewriting one's predecessors ' works is far more rewarding than being a blind toss? Blog frame structure are very similar, whether it is PHP or other programming language, if you want to complete a blog system independently, you can refer to the Mature blog system, WordPress is larger, suggest you start from Emlog, learn to use, and then learn two times to develop, and then to develop independently, take its essence, Add your own innovation and you will benefit. It's hard to write a powerful program with your own ability, not to mention you are learning, you can write a press release system to try, in fact, the principle is similar, mainly security. Can add me qq, I send my database design file to you. 4873473..
I wrote a blog system, written in TP3.2.3, recently wanted to rewrite with the YII framework. I feel like I might be besieged by the best bunch of programmers in the world, but in the spirit of sharing, send a link to the main title, carefully click, https:// github.com/tornadoweb/t Ornado/tree/master/demos/blog
PHP only needs to output the database, in JSON format output articles, such as content, by JS native parsing
Comments refer to external off-the-shelf commenting systems such as: Qdiscuss,
Why is it necessary to rely on the backend for a lot of things?