简体   繁体   中英

Creating my own PHP Framework

I'm planning on creating a small framework for a dynamic site. When creating a framework is there a standard or code of conduct which should I conclude ?

Other than a license for use, there is no standard documentation you are required to include. As for how to build the framework, as you are writing the lowest level components of the code, you get to decide how the files are built and used. Just create some PHP files and allow people to use them.

Taking a look at how existing frameworks are structured is a good way to get started. CodeIgniter is nicely commented and simple enough to understand, so that would be a good project to read through to get started.

Decide whether you framework is loosely-coupled or full-flowed MVC framework

Loosely-coupled framework is util/library based like Zend/Symfony, where you just provide all the classes and interfaces that a developer can use but you do not force a specific request-response flow.

Full-flowed provides and usually forces the developer to use the request flow that it has established, like CakePHP, CodeIgniter or Kohana.

p/s: sorry I don't know the actual terms for the framework categories.

Decide whether your framework is general purpose or targetted to specific use

General purpose is like Zend/Symfony/CakePHP where the framework is not designed with specific use in mind but rather to create a website/application. Specific use framework is like e-commerce, CMS or blog where it is designed to create a website for a very specific purpose.

You can have a look at coding standards , as well as designpatterns (especially the MVC pattern ).

Here's a good tutorial which should get you started building your own PHP framework .

A good practice is to look at other PHP frameworks like:

  • Zend Framework
  • Code Igniter
  • Yii
  • Symphony
  • ...

See list here for more PHP frameworks.

There is some good advice regarding PHP standards here: http://www.phptherightway.com . The site advises style recommendations known as PSR-0, PSR-1, et al.

There is no standard per se. Usually you would roll out your own framework - or any product really - to combat an existing problem that persists within all of the existing frameworks. However, if it is purely for educational purposes, I would suggest you build a framework around the problems you envisage you will have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM