PHP:个人框架 [英] PHP: A Personal Framework

查看:62
本文介绍了PHP:个人框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将使用PHP为我的Web项目编写一个框架. 请不要告诉我考虑使用某些现有框架(Cake,CodeIgniter,Symfony等)的信息-我已经看过它们并决定为自己编写一个.

I'm going to write a framework for my web projects in PHP. Please don't tell me about considering to use some existing framework (Cake, CodeIgniter, Symfony, etc.) - I have already had a look at them and decided to write one for myself.

框架本身将主要由模块系统,数据库处理程序和模板解析器组成. (当然还有很多其他事情)

The framework itself will mainly consist of a module system, a database handler and a template parser. (Many other things too, of course)

对于模块系统,我的意思是每个模块都只有一个PHP文件和一个或多个与其关联的模板. 一个示例模块为modules/login.php,该模块使用templates/login.tpl进行设计.

With module system I mean that every module has exactly one PHP file and one or more templates associated with it. An example module would be modules/login.php that uses templates/login.tpl for its design.

这几天,每个人都在谈论MVC(模型视图控制器)概念,并且大多数现有框架也都在使用它.

These days everyone(?) is talking about the MVC (Model View Controller) concept and most of the existing frameworks use it, too.

所以我的问题如下:

  • MVC对个人框架真的有效吗?
  • 使用模块系统会是个坏主意吗?
  • 您是否曾经为自己编写过一个框架?您的经历是什么?

推荐答案

MVC对个人框架真的有效吗?

是的,可以.虽然,这可能有点矫kill过正(如果您想学习的话,这不一定是一件坏事)

Yes, it can be. Although, it might be a little overkill (which, is not necessarily a bad thing if you are trying to learn)

使用模块系统会是个坏主意吗?

这绝不是一个坏主意.

您是否曾经为自己编写过一个框架?您有什么经验?

当我是实习生时,我为小组的PHP应用程序编写了一个通用的安全框架.我学到了很多东西,但是整个项目可能会从预先构建的解决方案中受益更多.

I wrote a common security framework for my group's PHP applications when I was an intern. I learned alot, but the project as a whole might have benefited more from a pre-built solution.

当然,如果我仅安装了预构建的解决方案,我将不会学到很多东西.因此,您始终必须考虑到这一点,尤其是对于个人项目.有时候,重新发明轮子是您将学到好东西的唯一方法.

Of course, I wouldn't have learned as much if I just installed a pre-built solution. So you always have to take that into account, especially for personal projects. Sometimes re-inventing the wheel is the only way you will learn something well.

这篇关于PHP:个人框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆