简体   繁体   English

PHP框架(cake / smarty):如何使用它以及何时使用?

[英]PHP framework (cake/smarty): How to use it and when?

Duplicate of 重复

What is a PHP Framework? 什么是PHP框架? and many more 等等

So far, I've been using PHP for small tweaks, mostly with WordPress. 到目前为止,我一直在使用PHP进行小调整,主要是使用WordPress。 What are PHP frameworks? 什么是PHP框架? Why do I need them? 我为什么需要它们? WHEN do I need them? 我什么时候需要它们?

Any insight will be helpful. 任何见解都会有所帮助。 Thanks. 谢谢。

Frameworks are organized groups of code or libraries, built on top of a language to either 框架是组织的代码或库组,建立在语言之上

  • Make Common Tasks Easy/Simple 使常见任务轻松/简单
  • Create a Consistent Way to Develop Applications 创建一致的方式来开发应用程序

Some frameworks are very restrictive (as in it's not easy to do things, unless you do them the 'framework' way), others are looser. 有些框架是非常严格的(因为它不容易做事,除非你以'框架'的方式做),其他框架则更宽松。 I've found Zend's Framework to be a good mix of both, making easy to use single components (for example, you can drop the 'Feed' library into your existing application without needing to rewrite the application the Zend way), or you can use the Zend MVC and Application libraries to for an entire application. 我发现Zend的框架是两者的良好组合,使得易于使用的单个组件(例如,您可以将'Feed'库放入现有应用程序而无需以Zend方式重写应用程序),或者您可以将Zend MVC和Application库用于整个应用程序。

I'd stay away from frameworks that are 'all or nothing'. 我会远离那些“全有或全无”的框架。

From Zend's Framework (restating the above, perhaps more completely): 来自Zend的框架(重述上述内容,可能更完整):

Zend Framework is an open source framework for developing web applications and services with PHP 5. Zend Framework is implemented using 100% object-oriented code. Zend Framework是一个开源框架,用于使用PHP 5开发Web应用程序和服务.Zend Framework使用100%面向对象的代码实现。 The component structure of Zend Framework is somewhat unique; Zend Framework的组件结构有点独特; each component is designed with few dependencies on other components. 每个组件的设计与其他组件的依赖性很小。 This loosely coupled architecture allows developers to use components individually. 这种松散耦合的架构允许开发人员单独使用组件。 We often call this a "use-at-will" design. 我们经常将其称为“随意使用”设计。

While they can be used separately, Zend Framework components in the standard library form a powerful and extensible web application framework when combined. 虽然它们可以单独使用,但标准库中的Zend Framework组件在组合时形成了一个功能强大且可扩展的Web应用程序框架。 Zend Framework offers a robust, high performance MVC implementation, a database abstraction that is simple to use, and a forms component that implements HTML form rendering, validation, and filtering so that developers can consolidate all of these operations using one easy-to-use, object oriented interface. Zend Framework提供了一个强大的,高性能的MVC实现,一个易于使用的数据库抽象,以及一个实现HTML表单呈现,验证和过滤的表单组件,以便开发人员可以使用一个易于使用的操作来整合所有这些操作,面向对象的接口。 Other components, such as Zend_Auth and Zend_Acl, provide user authentication and authorization against all common credential stores. 其他组件(如Zend_Auth和Zend_Acl)为所有常见凭据存储提供用户身份验证和授权。 Still others implement client libraries to simply access to the most popular web services available. 还有一些实现了客户端库,只需访问最流行的Web服务。 Whatever your application needs are, you're likely to find a Zend Framework component that can be used to dramatically reduce development time with a thoroughly tested foundation. 无论您的应用程序需求是什么,您都可能会找到一个Zend Framework组件,可以通过经过全面测试的基础大大缩短开发时间。

A framework tries to provide all the things that are common to every (or most) projects - html rendering, database access, and so on - in a way that's simple and easy to use. 框架试图以简单易用的方式提供每个(或大多数)项目共有的所有内容 - html呈现,数据库访问等。

You would use one to speed development, because you can skip all that stuff, and focus on what's unique to your project. 您可以使用一个来加速开发,因为您可以跳过所有这些内容,并专注于项目的独特之处。 Depending on the one you use, it can also add some security features by automatically escaping data on the way to the database, or to the screen. 根据您使用的那个,它还可以通过在前往数据库或屏幕的途中自动转义数据来添加一些安全功能。

I use them in any situation where I don't need something so custom that it's more work to bend the framework to my needs than to create the whole thing from scratch. 我在任何我不需要这样的东西的情况下使用它们,以便根据我的需要弯曲框架而不是从头开始创建整个东西。 That's pretty rare. 这非常罕见。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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