框架 - 什么是 PHP 框架?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/635007/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:19:54  来源:igfitidea点击:

Framework - what is a PHP framework?

phpframeworks

提问by Charles Darke

What are the advantages/disadvantages of using a PHP framework over just writing direct PHP code?

与直接编写 PHP 代码相比,使用 PHP 框架的优点/缺点是什么?

回答by Treb

A framework gives you standard solutions to typical problems, e.g. for an online shop that can cover the functionality for a customer login (including session handling), a shopping cart, placing orders...

框架为您提供了典型问题的标准解决方案,例如,可以涵盖客户登录(包括会话处理)、购物车、下订单等功能的在线商店。

The big advantage of using a framework is that

使用框架的最大优势在于

  1. You don't need to reinvent the wheel, the code is already there
  2. The code (usually) works, it is already tested
  3. Specifically for user authentication, you will most probably have fewer security leaks as if you invented something from scratch yourself
  1. 你不需要重新发明轮子,代码已经在那里了
  2. 代码(通常)有效,它已经过测试
  3. 特别是对于用户身份验证,您很可能会减少安全漏洞,就像您自己从头开始发明一样

The big disadvantage is that

最大的缺点是

  1. If you want to extend the functionality, you have to understand OPC (other peoples code)
  2. If the framework contains a security hole and an exploit is available, your site is immediately vulnerable, but you may not have the knowledge to fix it yourself. So you need to keep a constant lookout on security bulletins, updates, fixes etc.
  1. 如果你想扩展功能,你必须了解OPC(其他人的代码
  2. 如果框架包含安全漏洞并且存在漏洞利用,则您的站点立即易受攻击,但您可能不具备自行修复它的知识。因此,您需要不断关注安全公告、更新、修复等。

回答by mozboz

A framework is a library. You have an investment of time to learn how to use a library, but once you know how it works, you should get back your investment many times.

框架是一个库。您需要投入时间来学习如何使用库,但是一旦您知道它是如何工作的,您就应该多次收回您的投资。

A PHP web framework applies this principle to all the common things you do when you produce a (usually database driven) website with PHP.

PHP Web 框架将此原则应用于您使用 PHP 生成(通常是数据库驱动的)网站时所做的所有常见事情。

回答by vartec

As noted by Tomas and Ngu, the your question is duplicate.

正如 Tomas 和 Ngu 所指出的,您的问题是重复的。

What I'd recommend, that you first read what web framework is. http://en.wikipedia.org/wiki/Web_application_framework

我的建议是,您首先阅读什么是 Web 框架。 http://en.wikipedia.org/wiki/Web_application_framework