Need those knowledge reserves to develop your own PHP framework?

Source: Internet
Author: User
Tags spl php framework

Reply content:

A lot of people when they hear that people want to develop a framework, the first idea is to repeat the wheel.
In fact, the process of building a wheel is a rapid accumulation of knowledge, can quickly find their own shortcomings, and learn some of their own uncovered knowledge points. So it is advisable to try to complete a basic framework of perfectly formed in the case of a certain PHP base.

So let's share the process of making the wheel before:

1. Try more than one frame, read through the use of the document, the purpose is to understand what it has, and find some of his better usage design;
2. While looking at the document parallel thinking this part of the implementation of the principle, if you do not understand to write down or on GitHub to see the source (of course, not familiar with the code structure of the case may be difficult to find, so I suggest to write down first);
3. Look at its project structure, and think about the meaning of this structure, for example, what is the reason why most frameworks separate the entry file and static resources into the public directory separately from other directories;
4. Try to read the source code of the running process, from the entrance to the output, as well as error handling, template engine, configuration and other points to understand (if the basis allows, in the process to solve the above-mentioned doubt it);
5. Start your own implementation, write a general list of features, write the points you want to implement;
6. Then think about organizing your code structure and organizing it in the way you are most familiar with without much practical experience (first to achieve re-optimization);
7. Run through the basic Hello world! first;
8. Add a little bit of function;
9. Find deficiencies and improve it;

Here in the Add function, as far as possible to achieve their own implementation of all the components, such as file upload, error handling and so on, after all, the purpose is internship knowledge.
Then this process actually go down for the foundation slightly poor people may be particularly bad, so it doesn't matter, encounter which point stuck, first solve your problem on this point, quickly add knowledge back to continue.

Summarize some of the points commonly used in the framing process (the following permutations are not sequential):

1. MVC
2. Auto Load: PHP: Auto Load Class ;
3. Error Handling: / http Php.net/manual/zh/book. errorfunc.php ;
4. PHP standard library (SPL) php:spl-manual ;
5. Output buffering control: PHP: Output control ;
6. PHP Options/Information: php:php Options/Information ;
7. Database Abstraction Layer: PHP: Database Abstraction Layer ;
8. Session Expansion: Php:session extension ;
9. Reflections: / http Php.net/manual/zh/book. reflection.php ;
10. Classes and objects: PHP: Classes/objects ;
11. Image processing and Gd:php:gd-manual ;
12. Mail-related SMTP;
13. File System: Php:filesystem ;
14. Predefined variables: PHP: Predefined variables ;
15. String Processing: PHP: string-Manual ;
15. Regular Expressions: / http Php.net/manual/en/book. pcre.php ;

Basic probably above these also enough, although each link above gives a lot of content, but master commonly used is good, can combine search engine to understand.

If you want to add some more ingenious, or richer, functionality to the framework, here are some things to know:

1. Common Design Patterns: factory, single case, appearance, observer, etc.
2. Pre-defined interfaces such as iterators: PHP: Predefined interfaces
3. Database development: PHP: Database extension ;
4. Internationalization and character encoding support PHP: internationalization and character encoding support ;
5. Common cache, Redis, MEMCACHE,APC, etc.;
6. Queue services such as ACTIVEMQ,BEANSTALKD, etc.;
7. Multi-database support such as MONGO;
8. Events and hooks;

There is also a way to create a framework, but it is not appropriate to use "create", called the combo frame, that is, the use of composer Assemble a framework of your own based on open source components. Of course, this is not recommended for beginners to do so, which may give you a lot of basic things you can not get exercise. If the personal technical ability is already more mature, the goal is to develop the project quickly, use it is absolutely the sharp weapon.

Finally, some reference frames are recommended:

1. Slim Framework -Micro frame, a framework of basic functions are satisfied, very suitable for learning;
2. Silex -Micro-frame, based on Symfony2 components;
3. CodeIgniter -Very clear structure of PHP framework;

There are also some tutorials here, but it is recommended that you try it yourself first:

1. Write your own PHP MVC Framework (Part 1)
2. Use PHP to build your own MVC framework

---2015.02.28 supplement---
Looked downstairs everybody's answer, found everybody is irrelevant, test instructions is " need those knowledge reserves? "And not" How to complete a frame", to complete the framework of the method N, and according to some of the answers downstairs, completed also learned nothing, even why this can be used as a framework to run, the principle of the middle does not understand, so please carefully answer to avoid misleading others. It's actually very simple stuff.
First make sure you know the following:
1. Pass and accept parameter handling via URL
2. Know the meaning of the include
3. Echo and define functions.

OK, start
First, let's write a php file index.php, so that we can run different functions with different get parameters.

  
   
Learn to composer and watch this series.
Build your own PHP framework with Composer step-by-stephttps://phphub.org/topics/159

In fact, the people in the front have made it very clear,

You have this idea I have also experienced, simply said, the use of well-known products, is generally busy to achieve, lack of macro-awareness, so that the development of a framework is also very normal.

I also developed a, in fact, I think of no upstairs said so much,

Is simple routing distribution, MVC layering. The basic shelves are set up and gradually perfected.

At work, you can try your own frame when you meet a one-time small project that you only need to complete alone.

Proposed landlord to find a few simple frame to see, personal recommendation Codergniter, is the structure of the clearest frame.

Before looking at help, such as scholars with Laravel 5.0 developed a small application, but still feel a lack of confidence, feel that the framework is still a lack of understanding and understanding, I am learning Java, but see this framework so fire to try the next.

Problem:

Like PHP, want to learn to master PHP and Laravel, so that you have to learn from the basics, you can write a framework to do it? If you haven't written a frame, discuss the contents of each frame without being able to discuss it.
Finally wrote a framework out, the framework involves a lot of content, individuals feel that they write a framework for your own logical thinking, development architecture and the language has a qualitative improvement. I wrote the process of two version, referring to the CI TP yii Three framework of the source code (just look at their ideas, refine), the whole blog has been written nearly 20

Business:
Need knowledge
1 Route resolution
2 Routing Assignment
3 IoC
4 Database Encapsulation
5 Cache Package
6 Template Parsing File cache
7 Secure XSS SQL injection
8 HTTP Operations
9 Picture Operations
10, wait a lot.
Each piece will have a lot of knowledge.

Finally: the framework of your own writing
Fantiq/phpframework GitHubI'm doing this, but it's a comparative dish. Interested we can learn from each other (*^__^*) up posture not too early in-depth details, class library, plug-ins are clouds, framework framework, reasonable architecture specification is the most important.
To let the elephant dance, in a powerful premise, as light as possible, do not make reference to a bunch of classes, a bunch of configuration files.
Many frameworks can only be said to be a class library
  • Related Article

    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.