PHP has been used for a while. Okay, it's just for use. I have never done a large project, I only did simple module development, and I have seen YiiThinkPHPCI and other open-source frameworks. However, I only stay in the unknown state. I really want to build a framework by myself, and I want to make something from AM. I don't know where it comes from... PHP has been used for a while. Okay, it's just for use.
I have never done large projects, only developed simple modules, and learned about Yii ThinkPHP CI and other open-source frameworks.
However, I only stay in the unknown state and want to build a framework by myself. I want to create something from the perspective of Jian, who doesn't know where to start.
Please give me some advice.
Reply content:
PHP has been used for a while. Okay, it's just for use.
I have never done large projects, only developed simple modules, and learned about Yii ThinkPHP CI and other open-source frameworks.
However, I only stay in the unknown state and want to build a framework by myself. I want to create something from the perspective of Jian, who doesn't know where to start.
Please give me some advice.
I didn't want to answer this question. But after thinking for a while, I still need to talk about it.
First, you need to understand why you develop your own framework?
I don't think you really understand. To write a framework, I think it's cool, awesome, or just to make it easy,
Meet your habits.
The landlord is still in the initial stage and has not figured out the principles of several good frameworks, so he began to write the frameworks. I don't think it's very practical.
Location. When you understand the advantages and disadvantages of the current framework, the principle is not very convenient, or it is not very in line with your own ideas, habits, and so on.
You only need to develop. So that you have the strength to have a deep understanding.
I used a lot of projects and frameworks at the time. I felt that the framework was not very in line with my own ideas. Try to write
The framework of your thoughts.
The above is purely personal understanding. The words are not good. Please give me more advice.
Let us first say that the framework is used to solve the problem like other programs. If you haven't encountered any problems, why re-create the wheel?
Then let's talk about the verbose:
Most Web frameworks handle the following:
- Code reuse: defines the placement and loading rules of packages, classes, and functions. We recommend that you directly integrate Composer and Its AutoLoad features.
- Request Distribution Management: This is routing. Restful frameworks like Rewrite. A simple framework mainly uses parameters to locate the module and method.
- Configuration File Management: load and dynamically load configuration data
- Error and exception management: exception capture, error log records, and error code specifications.
- LayOut and template engine: how to plan page LayOut, how to reuse widgets, how to combine ajax pages, how to redirect expired sessions, how to render data and templates into HTML, whether to compress and set expiration headers.
- Database: how to integrate the controller, what driver is supported, the scalability of master-slave separation, and whether to use ORM.
These are the core frameworks. The periphery is another common component, and the plug-and-play mechanism should be well designed.
The implementation of large frameworks is complicated. You can start with some simple frameworks to learn about the advantages of large frameworks.
By the way paste a framework I wrote: https://github.com/easychen/lazyphp/tree/3.1
Generally, a single frame entry->Routing->Distribution->Rendering, adding some extensibility, adding interfaces or abstract classes to routing, distribution, and rendering, and adding composer to the convenience points. It is better to maintain the points and add modules, and then change the BUG ..
Tucao: Generally, it is better to use a mature open-source framework for formal projects.Independent Development FrameworkPersecution of programmers T_T, except for excellent autonomous frameworks.
The basic part of a general PHP framework should include functions and modules such as URL routing and request distribution, database connection and operations, template engine, common String Array Operations, and automatic loading, you can refer to some of the less obscure frameworks to learn and implement them step by step. However, high-quality frameworks are not encapsulated by class libraries and functions, it is also necessary to combine the above functional modules reasonably to play a huge role.
If you try to write your own framework, it is good to have such an idea. It means that you want to make progress and want to learn more.
I think writing a framework is a summary of the knowledge or experience you have learned. Only when you have more understanding and ideas about PHP and web programs, you have the goods to sum up these ideas and experiences through the framework.
We all write articles. Why can't we become writers?
So I don't think you should think about writing a framework. You should think about making yourself better understand PHP and web programs.
I recommend that you go to see more symfony author blog http://fabien.potencier.org/here every article is wonderful, his style is straightforward, easy to understand, there are some reasons for the explanation of the technology just like the teacher's class.
You can try to read the Sliex https://github.com/fabpot/Silex source code, which is another simple framework developed by the author of Symfony, not as complex as Symfony.
Finally, attach my own blog: http://www.tangrucheng.com, I am also a beginner, you can exchange and learn PHP
Find a framework and review it.
Then you don't have to ask this question any more.
If your goal is to "make something", the most reasonable/common thing is to write a blog program.
- There is no business empty writing framework, which requires a lot of experience (know the similarities and differences between different projects and the pain points of development), and blog programs are real businesses.
- The blog service is flexible and can be expanded and complicated almost infinitely from very small to small. It can also involve almost all aspects of a web.
- Blogs are deployed and launched on their own, with at least one management user (yourself) and several visitors. However, if you write a framework, you can't get around the embarrassment of "no one uses the project ".
Ad Time-My PHP framework LitPHP
Although version 0.2 has more than 10 lines, the number of lines of code in the 289 line should be the world's smallest PHP framework.
Http://litphp.github.io/
A rough look at the code for half an hour, and a careful look is the most for half a day. It should provide some ideas for writing the framework.
The php community has been very mature, and various models and styles of frameworks have been implemented. I personally think that you will develop a PHP framework again, simply to repeat the fun and sense of accomplishment of the wheel. Of course, if you have enough time and experience, you can try to develop a framework that suits your habits. On the one hand, you can understand the Framework Design and exercise your abilities.However, after you have used the frameworks of at least many different styles.
However, other emerging technologies, such as Node. js is still very young, and various packages and frameworks are not very mature. There are still a lot of gaps to be filled and there is no limit to possibilities. At this time, we can develop a framework.Community contribution.
Send me a Node. js framework: Codekart, official website, document manual
I don't agree. If it was just before I started, I would have thought like this. But now I will choose to use mainstream open-source frameworks.
You can write the framework by yourself. Of course, you can run it, but you have never experienced the test of time. After all, you need to rebuild it constantly!
After all, you cannot keep up with the evolution of php. php upgrades and framework upgrades will drive you crazy.
There are too many web mvc frameworks. We recommend that you turn to some unpopular frameworks, such as socket server frameworks, asynchronous frameworks, and mobile application frameworks.
"It's been a while to use PHP. Okay, just use it ". The usage time is estimated to be a little short. It is recommended that you familiarize yourself with some common PHP frameworks, such as CI, YII, thinkphp, Laravel, and symfony within three years of contact with PHP, when the fire is reached, consider writing your own framework. In fact, it makes sense to use the existing framework or develop your own framework. The premise is that you have learned the advantages and disadvantages of some other frameworks before developing the framework, so that you can develop a better framework. If you only want to use the Framework to quickly develop products, we recommend that you use the existing framework.
The main advantage of self-developed frameworks is that you can learn how to write frameworks. If you want to know how to compile a framework, I suggest you start by customizing a framework and change it to what you need or want. Learn the main implementation process and what features of the language are used. After continuous customization and modification, you finally get rid of the core part of the code as you want.
Of course, there are also many things to think about and learn from in this process, such as how to support multithreading, multi-process, asynchronous logs, and so on, and how to optimize the cli Mode
Https://github.com/lloydzhou/router
You can see