symfony_Symfony在Drupal 8中-程序员宅基地

技术标签: spring  ViewUI  python  java  编程语言  javascript  

symfony

If you are a Drupaler, you must be aware that Drupal 8 is on the way. What you may not know is that it includes a few important Symfony components. Working with Drupal 8.x will give Drupalers an opportunity to become a part of a massive learning curve and is going to tempt them to know more about Symfony. In this article, we discuss the Symfony components that have been added to Drupal 8, covering some third party libraries along the way.

如果您是Drupaler,则必须知道Drupal 8即将推出。 您可能不知道的是,它包含一些重要的Symfony组件。 使用Drupal 8.x将使Drupalers有机会成为大规模学习曲线的一部分,并将诱使他们更多地了解Symfony。 在本文中,我们讨论了已添加到Drupal 8中的Symfony组件,涵盖了一些第三方库。

Before we get into the actual article, let us first briefly cover Symfony. It is a PHP based web application framework that follows the MVC architecture. Moreover, it is an open source project that has been released under the MIT license. Please make sure you don’t get it confused with Symfony CMS. If you wish to explore the Symfony framework into greater detail, see its Wiki page or any of the previous SitePoint articles about it.

在进入实际文章之前,让我们首先简要介绍一下Symfony 。 它是遵循MVC架构的基于PHP的Web应用程序框架。 此外,它是一个开放源代码项目,已根据MIT许可发布。 请确保您不要将它与Symfony CMS混淆。 如果您想更详细地探索Symfony框架 ,请参阅其Wiki页面有关它的以前的SitePoint文章

Now let’s learn about the Symfony components that are being implemented in Drupal 8.

现在让我们了解在Drupal 8中实现的Symfony组件。

Drupal 8.x中的Symfony组件 (Symfony components in Drupal 8.x)

The following are the Symfony components that are going to power the Drupal 8 core to a major extent:

以下是将在很大程度上为Drupal 8核心提供动力的Symfony组件:

  • HttpKernel and HttpFoundation – These are responsible for streamlining the process of converting a Request into a Response with the help of EventDispatcher. Drupal 8 being moved to Symfony was driven by Web Services and Content Core Initiative (WSCCI) in a motive to transform Drupal from a first-class CMS to a first-class REST server with first-class CMS running on top of it. This initiative is intended to allow Drupal to use web services to offer its content with reduced complexity; considering this as a long term vision, Drupal will be more flexible, robust and easily maintainable CMS.

    HttpKernelHttpFoundation –负责借助EventDispatcher简化将请求转换为响应的过程。 由Web服务和内容核心计划(WSCCI)驱动的Drupal 8迁移到Symfony的动机是,将Drupal从一流的CMS转变为一流的 REST服务器,并在其之上运行一流的CMS。 该计划旨在使Drupal能够使用Web服务以降低复杂性的方式提供其内容; 考虑到这是一个长远的愿景,Drupal将成为更加灵活,强大和易于维护的CMS。

  • EventDispatcher – Implements the Mediator pattern (that uses encapsulation) in a simple and effective manner especially where code inheritance doesn’t work out, making the application highly extensible. It is more effective in situations where you tend to maintain and/or refactor a program consisting of a huge number of classes due to the fact that it makes the communication amongst the classes quite simple and easy.

    EventDispatcher –以简单有效的方式实现Mediator模式 (使用封装),尤其是在代码继承无法解决的情况下,从而使应用程序具有高度可扩展性。 在您倾向于维护和/或重构包含大量类的程序的情况下,这种方法更为有效,因为它使类之间的通信变得非常简单和容易。

  • ClassLoader – Provides tools that autoload classes and caches their location. PHP uses the autoloading mechanism to delegate the loading of a file that defines the class in situations where you reference a class that has not been required or included yet. Symfony comes with autoloaders like PSR-0 Class Loader and MapClassLoader. Implementing the ClassLoader component will make Drupal module developers carefree especially when it comes to implementing module_load_include and other dependencies. Moreover, it allows developers easy calling of classes during run-time.

    ClassLoader –提供自动加载类并缓存其位置的工具。 PHP使用自动加载机制来委托在定义了不需要或不包含的类的情况下定义该类的文件的加载。 Symfony附带了PSR-0 Class LoaderMapClassLoader等自动加载器。 实现ClassLoader组件将使Drupal模块开发人员无忧无虑,尤其是在实现module_load_include和其他依赖项时。 而且,它允许开发人员在运行时轻松地调用类。

  • YAML – It parses YAML strings and converts them to PHP arrays and vice versa. This format has been especially designed to hold configuration related information, while being as expressive as XML files and as readable as INI files. It serves as an integral component of Drupal’s CMI (Configuration Management Initiative) that allows our modules to initially define their default configuration settings and later allows the site builder to override the same as-and-when instructed to. This concept of Drupal 8’s CMI which is powered by YAML is a replacement for Features contributed Drupal module which proves to be a robust concept as far as migrating and deploying across environments is concerned.

    YAML –解析YAML字符串并将其转换为PHP数组,反之亦然。 该格式经过专门设计,可保存与配置有关的信息,同时具有与XML文件一样的表现力和与INI文件一样的可读性。 它是Drupal的CMI (配置管理计划)的组成部分,它允许我们的模块最初定义其默认配置设置,后来允许站点构建者按要求覆盖相同的内容。 由YAML提供支持的Drupal 8的CMI概念替代了Features贡献的Drupal模块 ,事实证明,就跨环境迁移和部署而言, Drupal模块是一个可靠的概念。

  • Routing – Allows us to load all routes, and dumps a URL matcher or generator specific to these routes. This also means that it maps an HTTP request to a set of configuration variables. As far as Drupal 8 and above versions are concerned, we define our module’s routes in a YAML configuration file, each of them set to trigger a specific action that has been defined in our module’s classes.

    路由 -允许我们加载所有路由,并转储特定于这些路由的URL匹配器或生成器。 这也意味着它将HTTP请求映射到一组配置变量。 就Drupal 8及更高版本而言,我们在YAML配置文件中定义了模块的路由,每个路由都设置为触发在模块类中定义的特定操作。

  • DependencyInjection – Primarily used to standardize and centralize the way objects are constructed in our application. Symfony’s DependencyInjection component has been incorporated in Drupal 8 in an intention to write code in such a way that classes can be reused and unit-tested wherever applicable and desired.

    DependencyInjection –主要用于标准化和集中化应用程序中对象构造的方式。 Symfony的DependencyInjection组件已合并到Drupal 8中,目的是编写代码,以便可以在适用和需要的地方重用和进行类测试。

  • Twig – Drupal 8 has adopted the Twig template engine. This is of interest to the themers who will probably never think of any other option again for as long as they’re working on Drupal themes. Twig was developed by Fabien Potencier, who also developed the Symfony project, and was fine tuned for integration into Drupal 8.

    Twig – Drupal 8采用了Twig模板引擎。 这些主题使那些感兴趣的人感兴趣,只要他们正在研究Drupal主题,他们就永远不会再考虑任何其他选择。 Twig由Fabien Potencier开发,他还开发了Symfony项目 ,并进行了微调以集成到Drupal 8中。

  • Process – Helps execute commands in sub-processes using the command-line interface. Drupal 8 will use this to handle all activities that are command-line in nature.

    流程 –使用命令行界面帮助在子流程中执行命令。 Drupal 8将使用它来处理本质上是命令行的所有活动。

  • alt

    Serializer – It is used to transform objects into a specific format (eg. XML, YAML, JSON, etc.) and vice versa. To understand it better, let us look at the following schema that a Serializer component follows:

    序列化器 –用于将对象转换为特定格式(例如XML,YAML,JSON等),反之亦然。 为了更好地理解它,让我们看一下序列化器组件遵循的以下架构:

    Additionally, we can use it to accomplish a number of jobs, ranging from configuration to node and entity creation that should be delivered by a REST endpoint.

    另外,我们可以使用它来完成许多工作,从配置到节点和实体创建,这些工作都应该由REST端点交付。

  • Validator – Helps Drupal validate values. For example: validating form submission, validating entities within Drupal, etc. To accomplish its job, it uses Doctrine Annotations (discussed in Out-of-the-box third party components section).

    验证器 –帮助Drupal验证值。 例如:验证表单提交,验证Drupal中的实体等。为了完成其工作,它使用“学说注释” (在即用的第三方组件部分中讨论)。

  • Translation – Provides a standard set of tools to load translation files, generate translated strings as output, and use the generated outcome.

    翻译 –提供一组标准工具来加载翻译文件,生成翻译后的字符串作为输出以及使用生成的结果。

开箱即用的第三方组件 (Out-of-the-box third party components)

We went through Symfony components that have been included with Drupal 8. In this section, we’ll find out about the 3rd party PHP components that have been implemented in Drupal 8 and are not related to Symfony. They are:

我们研究了Drupal 8随附的Symfony组件。在本节中,我们将了解在Drupal 8中实现的与Symfony无关的第三方PHP组件。 他们是:

  • Assetic – An Asset Management framework. Assets in Drupal consist of CSS files, JavaScript files, images, other media files, metadata, etc. These assets contain filterable content that can be loaded and dumped. In order to manipulate assets, you need to apply appropriate filters. To understand the filters, in what situations each can be used, how-to use the filters, build, dump, and much more, we recommend you read the Assetic Github page.

    Assetic - 资产管理框架 。 Drupal中的资产由CSS文件,JavaScript文件,图像,其他媒体文件,元数据等组成。这些资产包含可加载和转储的可过滤内容。 为了操纵资产,您需要应用适当的过滤器。 要了解过滤器,在什么情况下可以使用每种过滤器,如何使用过滤器,构建,转储等等,我们建议您阅读Assetic Github页面

  • Composer – A tool specifically designed and developed to manage dependency in PHP allowing us to declare the dependent libraries our project needs and install them for us. Though it deals in packages and libraries, it is not a package manager. Composer is a boon to Drupal 8 due the following:

    Composer –专为开发和管理 PHP中的依赖关系而设计和开发的工具,使我们能够声明项目所需的依赖库并为我们安装它们。 尽管它处理软件包和库,但它不是软件包管理器。 Composer得益于Drupal 8:

    • Handles situations very efficiently wherein your project is dependent upon a number of libraries.

      非常有效地处理您的项目依赖于许多库的情况。

    • Tackles situations where there is a nested dependency concept amongst the libraries. For instance; your project is dependent upon a library (say, lib1) and in tern lib1 is dependent upon some other library (say, lib2).

      解决在库之间存在嵌套依赖项概念的情况。 例如; 您的项目依赖于一个库(例如, lib1 ),而lib1则依赖于其他某个库(例如, lib2 )。

    • It is Composer’s responsibility to choose which version of the package or library needs to be installed unless explicitly told which versions to target.

      除非明确告知要定位的版本,否则Composer的责任是选择需要安装软件包或库的哪个版本。

  • Doctrine – A bundle of tools for use with database records. Drupal 8 uses a part of it called Annotations that exposes additional metadata to Drupal. Efforts have been made to present such tricky functionality in a quite easy and handy way, especially when defining custom entity types. If you wish to explore further on how Doctrine is supposed to be used with Drupal 8, we recommend you visit the documentation page.

    原则 –一整套用于数据库记录的工具。 Drupal 8使用它的一部分,称为Annotations ,它将其他元数据公开给Drupal。 已经做出努力以相当容易和方便的方式呈现这种棘手的功能,尤其是在定义自定义实体类型时。 如果您想进一步研究Drupal 8应该如何使用Doctrine,我们建议您访问文档页面

  • EasyRDF – A PHP library that has been used with Drupal 8 so as to provide ease in consuming and producing RDF. With the help of EasyRDF, Drupal 8 adds capability to produce metadata in the markup in an easy and convenient way. You may also visit EasyRDF official site to learn more about it.

    EasyRDF –一个PHP库,已与Drupal 8一起使用,以简化使用和生产RDF的过程。 在EasyRDF的帮助下,Drupal 8添加了以简单便捷的方式在标记中生成元数据的功能。 您也可以访问EasyRDF官方网站以了解更多信息。

  • Guzzle – It is a PHP HTTP client and framework that helps Drupal 8 make web requests using REST based web service calls. This makes Drupal 8 web portals more efficient in terms of handling different sorts of web services. To explore further on Guzzle, we recommend reading our previous article on it.

    Guzzle –它是一个PHP HTTP客户端和框架,可帮助Drupal 8使用基于REST的Web服务调用来发出Web请求。 这使得Drupal 8 Web门户在处理各种Web服务方面更加高效。 要进一步研究Guzzle,建议您阅读之前的文章

  • PHPUnit – Used in Drupal 8 to standardize unit testing throughout the core as well as help developers write code that is of utmost quality. PHPUnit ensures that any code written in Drupal 8 and in any custom module incorporated in it matches industry standards and works as expected throughout its life-cycle. You may keep an eye on the current status of PHPUnit’s incorporation into Drupal 8 by going here.

    PHPUnit –在Drupal 8中用于标准化整个核心的单元测试,并帮助开发人员编写最高质量的代码。 PHPUnit确保以Drupal 8编写的任何代码以及包含在其中的任何自定义模块中的任何代码均符合行业标准,并在其整个生命周期中都能正常工作。 您可以通过此处随时了解PHPUnit并入Drupal 8的当前状态。

  • PSR-3 Logging – A common logging system that is shared by an entire PHP application. Drupal 7 and older versions use watchdog() for this purpose. Switching Drupal logging from watchdog() to a PSR-3 logging framework has made Drupal 8 more robust and scalable in terms of common logging. You may track the current status of this component at Switch watchdog to a PSR-3 logging framework.

    PSR-3日志记录 –整个PHP应用程序共享的通用日志记录系统。 Drupal 7和更早的版本为此使用watchdog() 。 将Drupal日志记录从watchdog()切换到PSR-3日志记录框架,使Drupal 8在普通日志记录方面更加强大和可扩展。 您可以在Switch Watchdog到PSR-3日志记录框架中跟踪此组件的当前状态

结论 (Conclusion)

The introduction of a few Symfony components has simplified working with Drupal 8. Additionally, including a few of the non-Symfony components has added value to Drupal 8 in terms of its quality, scalability, and performance, making it even more robust and maintainable.

一些Symfony组件的引入简化了Drupal 8的工作。此外,包括一些非Symfony组件在质量,可伸缩性和性能方面为Drupal 8增添了价值,使其更加健壮和可维护。

翻译自: https://www.sitepoint.com/symfony-drupal-8/

symfony

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/culh2177/article/details/108384793

智能推荐

5个超厉害的资源搜索网站,每一款都可以让你的资源满满!_最全资源搜索引擎-程序员宅基地

文章浏览阅读1.6w次,点赞8次,收藏41次。生活中我们无时不刻不都要在网站搜索资源,但就是缺少一个趁手的资源搜索网站,如果有一个比较好的资源搜索网站可以帮助我们节省一大半时间!今天小编在这里为大家分享5款超厉害的资源搜索网站,每一款都可以让你的资源丰富精彩!网盘传奇一款最有效的网盘资源搜索网站你还在为找网站里面的资源而烦恼找不到什么合适的工具而烦恼吗?这款网站传奇网站汇聚了4853w个资源,并且它每一天都会持续更新资源;..._最全资源搜索引擎

Book类的设计(Java)_6-1 book类的设计java-程序员宅基地

文章浏览阅读4.5k次,点赞5次,收藏18次。阅读测试程序,设计一个Book类。函数接口定义:class Book{}该类有 四个私有属性 分别是 书籍名称、 价格、 作者、 出版年份,以及相应的set 与get方法;该类有一个含有四个参数的构造方法,这四个参数依次是 书籍名称、 价格、 作者、 出版年份 。裁判测试程序样例:import java.util.*;public class Main { public static void main(String[] args) { List <Book>_6-1 book类的设计java

基于微信小程序的校园导航小程序设计与实现_校园导航微信小程序系统的设计与实现-程序员宅基地

文章浏览阅读613次,点赞28次,收藏27次。相比于以前的传统手工管理方式,智能化的管理方式可以大幅降低学校的运营人员成本,实现了校园导航的标准化、制度化、程序化的管理,有效地防止了校园导航的随意管理,提高了信息的处理速度和精确度,能够及时、准确地查询和修正建筑速看等信息。课题主要采用微信小程序、SpringBoot架构技术,前端以小程序页面呈现给学生,结合后台java语言使页面更加完善,后台使用MySQL数据库进行数据存储。微信小程序主要包括学生信息、校园简介、建筑速看、系统信息等功能,从而实现智能化的管理方式,提高工作效率。

有状态和无状态登录

传统上用户登陆状态会以 Session 的形式保存在服务器上,而 Session ID 则保存在前端的 Cookie 中;而使用 JWT 以后,用户的认证信息将会以 Token 的形式保存在前端,服务器不需要保存任何的用户状态,这也就是为什么 JWT 被称为无状态登陆的原因,无状态登陆最大的优势就是完美支持分布式部署,可以使用一个 Token 发送给不同的服务器,而所有的服务器都会返回同样的结果。有状态和无状态最大的区别就是服务端会不会保存客户端的信息。

九大角度全方位对比Android、iOS开发_ios 开发角度-程序员宅基地

文章浏览阅读784次。发表于10小时前| 2674次阅读| 来源TechCrunch| 19 条评论| 作者Jon EvansiOSAndroid应用开发产品编程语言JavaObjective-C摘要:即便Android市场份额已经超过80%,对于开发者来说,使用哪一个平台做开发仍然很难选择。本文从开发环境、配置、UX设计、语言、API、网络、分享、碎片化、发布等九个方面把Android和iOS_ios 开发角度

搜索引擎的发展历史

搜索引擎的发展历史可以追溯到20世纪90年代初,随着互联网的快速发展和信息量的急剧增加,人们开始感受到了获取和管理信息的挑战。这些阶段展示了搜索引擎在技术和商业模式上的不断演进,以满足用户对信息获取的不断增长的需求。

随便推点

控制对象的特性_控制对象特性-程序员宅基地

文章浏览阅读990次。对象特性是指控制对象的输出参数和输入参数之间的相互作用规律。放大系数K描述控制对象特性的静态特性参数。它的意义是:输出量的变化量和输入量的变化量之比。时间常数T当输入量发生变化后,所引起输出量变化的快慢。(动态参数) ..._控制对象特性

FRP搭建内网穿透(亲测有效)_locyanfrp-程序员宅基地

文章浏览阅读5.7w次,点赞50次,收藏276次。FRP搭建内网穿透1.概述:frp可以通过有公网IP的的服务器将内网的主机暴露给互联网,从而实现通过外网能直接访问到内网主机;frp有服务端和客户端,服务端需要装在有公网ip的服务器上,客户端装在内网主机上。2.简单的图解:3.准备工作:1.一个域名(www.test.xyz)2.一台有公网IP的服务器(阿里云、腾讯云等都行)3.一台内网主机4.下载frp,选择适合的版本下载解压如下:我这里服务器端和客户端都放在了/usr/local/frp/目录下4.执行命令# 服务器端给执_locyanfrp

UVA 12534 - Binary Matrix 2 (网络流‘最小费用最大流’ZKW)_uva12534-程序员宅基地

文章浏览阅读687次。题目:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93745#problem/A题意:给出r*c的01矩阵,可以翻转格子使得0表成1,1变成0,求出最小的步数使得每一行中1的个数相等,每一列中1的个数相等。思路:网络流。容量可以保证每一行和每一列的1的个数相等,费用可以算出最小步数。行向列建边,如果该格子是_uva12534

免费SSL证书_csdn alphassl免费申请-程序员宅基地

文章浏览阅读504次。1、Let's Encrypt 90天,支持泛域名2、Buypass:https://www.buypass.com/ssl/resources/go-ssl-technical-specification6个月,单域名3、AlwaysOnSLL:https://alwaysonssl.com/ 1年,单域名 可参考蜗牛(wn789)4、TrustAsia5、Alpha..._csdn alphassl免费申请

测试算法的性能(以选择排序为例)_算法性能测试-程序员宅基地

文章浏览阅读1.6k次。测试算法的性能 很多时候我们需要对算法的性能进行测试,最简单的方式是看算法在特定的数据集上的执行时间,简单的测试算法性能的函数实现见testSort()。【思想】:用clock_t计算某排序算法所需的时间,(endTime - startTime)/ CLOCKS_PER_SEC来表示执行了多少秒。【关于宏CLOCKS_PER_SEC】:以下摘自百度百科,“CLOCKS_PE_算法性能测试

Lane Detection_lanedetectionlite-程序员宅基地

文章浏览阅读1.2k次。fromhttps://towardsdatascience.com/finding-lane-lines-simple-pipeline-for-lane-detection-d02b62e7572bIdentifying lanes of the road is very common task that human driver performs. This is important ..._lanedetectionlite

推荐文章

热门文章

相关标签