开发者

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 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜