ASP.NET 开发人员尝试学习 Drupal 和 PHP

发布于 2024-08-10 19:25:32 字数 1436 浏览 2 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

青春有你 2024-08-17 19:25:32

恐怕我没有任何 Drupal 的经验,所以我无法对你的第一个问题或第二个问题提供任何见解,但关于第三个问题:

最好/最简单的处理方法是什么
MS SQL 数据库和/或 MySQL
正在使用和更新的数据库
多个 Drupal 和 ASP.NET
应用程序?

如果您要从 ASP.NET 应用程序和 PHP/Drupal 应用程序执行 CRUD 操作,那么我建议您不要尝试在 MySQL 和 MSSQL 之间来回同步数据,因为这会导致延迟问题,而且您还会遇到处理两个数据库管理系统之间的差异。

相反,我建议您考虑使用存储过程来控制所有数据库访问。这样您就可以确保所有数据库 CRUD 操作都符合相同的规则和逻辑。

在 ASP.NET 和 PHP 中使用 MSSQL 应该不是问题,尤其是使用非常优秀的 PDO 库,该库提供了用于访问许多流行数据库管理系统的标准接口。它应该允许您快速轻松地连接并开始在 PHP 应用程序中使用 MSSQL 数据库。

I'm afraid that I don't have any experience with Drupal so I can't offer any insights into your first or second questions, but on the third question:

What is the best/easiest way to handle
MS SQL databases and/or MySQL
databases being used and updated by
multiple Drupal and ASP.NET
applications?

If you are going to perform CRUD operations from both your ASP.NET applications and your PHP/Drupal applications, then I would recommend against trying to sync data back and forth between MySQL and MSSQL since this will cause latency problems plus you'll then have to deal with the differences between the two database management systems.

Instead, I would recommend that you look at using stored procedures to control all database accesses. This way you can ensure that all of your database CRUD operations conform to same rules and logic.

Using MSSQL in both ASP.NET and PHP shouldn't be a problem, especially not with the very excellent PDO library that provides a standard interface for accessing a number of popular database management systems. It should allow you to quickly and easily connect with and begin using your MSSQL databases within your PHP applications.

挽清梦 2024-08-17 19:25:32

你问的一些问题很好。我会尽力回答他们。我没有任何 APS.NET 的 c# 经验,所以我不知道你到底来自哪里。我自己是作为一个没有经验的 python/django 开发人员学习 Drupal 的。所以在某些方面我可以理解你在尝试学习Drupal时遇到的一些麻烦。其中一些事情只需要时间/经验/实验才能消失。

  1. 要真正了解 Drupal 和 Drupal API,您首先需要很好地了解 PHP。有时Drupal会做一些复杂的PHP事情,所以如果你不理解语法或PHP函数等,你很容易迷失方向。

    • 代码存放在哪里?
      Drupal 被构建为一个模块系统。 Drupal 本身是一组模块,其中一些模块是 Drupal 正常工作所必需的。如果您想编写一些自定义代码,那就是您想做一些无法使用模块的事情。 大约有 5000 个为 Drupal 开发的模块。通常,即使是一名熟练的程序员,最好的选择也是找到一个能够满足您需要或可以满足您需要的模块。因此,您要做的就是创建一个自己的模块。

      1. 使用模块名称创建一个文件夹

      2. 在其中创建一个 modulename.info,其中包含有关以特殊方式格式化的模块的一些信息。 Drupal 将需要它在您激活模块的模块列表页面上显示模块。

      3. 最后创建一个 modulename.module 文件,该文件的核心代码将位于其中。

      理解 Drupal 的另一件事很重要,那就是它使用基于钩子的系统。挂钩就像事件,一旦您想要挂钩的某些事情发生,要么改变流程,要么做一些您自己的事情,就会触发这些事件。 Fx,您可以在每次显示特定表单时进行记录,或者您可以更改表单,添加/删除字段。

    • 表单
      Drupal 有一个 FAIP 或表单 API,用于生成表单,它在文档中有自己的页面。这个想法是,您创建一个关联的 PHP 数组,其中保存有关表单的每个元素的信息,Drupal 将使用它来创建表单。

    • 书籍
      有很多关于 Drupal 的好书可供您学习。我自己学到最多的书是Pro Drupal Development

  2. 首先,Drupal有一个基于非常细粒度的角色的权限系统,这将允许您准确设置允许您的客户执行的操作。您可以创建不同的角色,例如主持人、内容创建者、管理员、系统管理员等,并为每个角色授予不同的权限。这非常简单,并且可以在 Drupal AI 中进行设置。但是,您需要了解权限,因为有些权限是超级权限,可以访问很多内容。现在,为了集成您的应用程序,您可能需要为其编写自定义模块。我不知道你到底想怎么做。但我认为最好的结果是让 Drupal 从您的应用程序创建页面、表单等,然后来回发送数据。这样网站的主题=布局就会保持一致。这样用户就不会感觉到他们离开了网站,但这只是网站提供的另一个功能。

  3. Drupal 不仅设置为最好地处理 MYSQL,您实际上需要 MYSQL 或 PSQL 作为您的 drupal 数据库后端。原因是 Drupal 处理查询的方式,它允许您编写有效的非特定查询,无论您使用两种类型中的哪一种,或者您的表是否有前缀。因此,对于所有 Drupal 内部结构,您将需要两者之一。 PHP 可以连接到 MSSQL 并针对该数据库运行查询,因此您可以毫无问题地编写自定义代码来对其他应用程序的数据库运行查询并获取或更新数据。根据数据的不同,您可能需要在数据库中创建一个可以读取和写入的表,然后在需要时同步数据库。这有点取决于您的用例。我已经完成了后者,在这种情况下,我不需要写入数据库,而只需要从仍在被其他系统使用的遗留数据库中获取一些产品信息。

It is some good questions you ask. I'll try to answer them to the best of my ability. I haven't any experience with c# of APS.NET, so I don't know exactly where you are coming from. I myself learned Drupal as an inexperienced python/django developer. So in some ways I can understand some of the troubles you are going through trying to learn Drupal. Some of these things will simply require time/experience/experimenting before it will go away.

  1. To really understand Drupal and the Drupal API you will first need a good understanding of PHP. Sometimes Drupal do some complex PHP things, so if you don't understand the syntax or the PHP functions etc, you can easy get lost.

    • Where do code live?
      Drupal is built as a moduler system. Drupal itself is a set of modules, some of which are required for Drupal to work properly. If you want make some custom code, that is you want to do something, that you can't use a module for. There are about 5000 modules developed for Drupal. Often even when being a skilled programmer, the best choice is to find a module that will do what you need or can get you where close. So what you do, it to create a module of your own.

      1. Make a folder with the name of the module

      2. Create a modulename.info inside it which holds some info about the module formatted in a special way. Drupal will need it to fx display the module on the module list page where you activate modules.

      3. Lastly create a modulename.module file where the core of your code for the module will be.

      Another thing that is important to understand with Drupal, is that it uses a hook based system. Hooks are like events that fire once certain things happen that you want to hook into and either alter the flow, or do some things of your own. Fx you could record every time a specific form was displayed, or you could alter the form, adding/removing fields.

    • Forms
      Drupal has a FAIP or Form API, that is uses to generate form, this is something that has it's own page in the documentation. The idea is that you create an associative PHP array which holds information about each element of the form, and Drupal will use that to create the form.

    • Books
      There are a lot of good books for Drupal that you can learn from. The book I myself have learned the most from is Pro Drupal Development

  2. First of all, Drupal has a very fine grained role based permission system, that will allow you to setup exactly what your clients are allowed to do. You can create different roles, like moderator, content creator, admin, sysadmin ect, and give different permissions to each role. This is pretty easy and is setup within the Drupal AI. However, you will need to know the permissions as some are super permissions that will give access to a lot of things. Now for integrating your applications, that is something that you probably want to write a custom module for. I don't know exactly how you want to do this. But I think the best result would be gotten by letting Drupal create the pages, forms etc from your application and just send data back and forth. That way the theme = layout of the site would be consistent. That way users wouldn't get the feeling that they left the site, but this simply was yet another feature the site offered.

  3. Drupal is not just set to handle MYSQL best, You will actually need either MYSQL or PSQL as your drupal database backend. The reason is the way Drupal handles queries, that allow you to write non specific queries that will work, no matter on which of the two types you use, or if your tables has a prefix. So for all of the Drupal internals you will need one of the two. PHP can connect to MSSQL and run queries against that database, so you could without much problems write custom code that run queries to your other application's databases and either fetch or update data. Depending on the data, you might want to create a table in your database that you can read and write to, and then sync the databases when needed. It depends a bit on your use case. I have done the latter, in the case where I didn't need to write to the database, but only needed to fetch some product information form a legacy database that was still being used by other systems.

非要怀念 2024-08-17 19:25:32

首先,我认为了解 Drupal 的局限性很重要,有些事情它并不是真正适合的。它是一种 Web 应用程序框架,但如果您使用自己的自定义数据建模等内容进行大量自定义工作,那么 Drupal 可能不是针对您的此类问题的最灵活或最容易实现的解决方案。更通用的框架(例如 Zend Framework)可能更适合。

学习 Drupal 的一个重要教训是:不要破解核心或其他模块。这将使升级核心或模块非常耗时。相反,“像 Drupal 一样”并使用钩子覆盖。在主题化中,您还可以使用钩子进行覆盖,但也可以通过其他方式进行覆盖。覆盖非常强大,因此请充分理解该概念。

  1. 我想说,选择一种适合您风格的学习方式:截屏视频、IRC、黑客、IRL 用户聚会、书籍、文章或任意组合,然后在 Drupal 上寻找材料。开始摸索并感受和理解 Drupal 的工作原理。理解术语是一个重要的部分,那么什么是:节点、块、区域、钩子、模块、主题。
  2. Drupal 有一个非常灵活的权限系统,使用它可能是最好的选择,而不是自己创建。您可以编写自己的模块来添加或更改 Drupal 的行为。因此,如果您想编写一个与 Drupal 一起使用的新应用程序,您可以编写一个模块来执行该应用程序必须具有的功能,并利用 Drupal 提供的所有设施,包括用户、权限系统等。我不这样做没有真正理解你的第二个问题的最后部分“drupal应用程序是drupal网站内自己的drupal实例(嵌套drupals?)?”。 Drupal 是服务器上 PHP 文件的集合,与数据库中的大量表一起服务向其发出的请求。多个 Drupal 网站(因此不同的 PHP 文件)可以引用相同的数据库或其部分(例如用户表)。没有真正的 Drupal 站点“实例”,因为没有真正的“应用程序”。我当然可能对这些术语太不熟悉,但我不认为 PHP 可以与“应用程序”的“实例”一起工作。

  3. 这是一个难题,据我所知,Drupal 不能与 MS SQL 一起使用,因此您可能必须自己建立该方向的任何连接。我还会在 Drupal 论坛或 IRC 上询问。

祝你好运!

First of all, I think what's important to understand Drupal's limitations, there are things it's not really made for. It's sort of a web application framework but if you're doing a lot of custom work with your own custom datamodelling and stuff, Drupal might not be the most flexible or easily implementable solution to your kinds of problems. A more general framework like for instance Zend Framework might be more suited.

An important lesson in learning Drupal is: don't hack core or other modules. This will make upgrading core or modules very time-consuming. Instead "do like Drupal" and override using hooks. In theming you can also override with hooks, but also in other ways. Overriding is powerful so understand that concept well.

  1. I'd say, pick a way of learning that is your style, screencasts, IRC, hacking, user meetups IRL, books, articles or any combination and look for material on Drupal. Just start mucking around and get a feeling and understanding of how Drupal works. Understanding the jargon is an important part, so what are: nodes, blocks, regions, hooks, modules, themes.
  2. Drupal has a very flexible permission system, and it's probably the best choice to use that instead of making your own. You can write your own modules that add to or alter the behavior of Drupal. So if you want to write a new application that works with Drupal you can write a module performing the functionality the application has to have and make use of all the facilities Drupal offers, including users, the permission system, etc, etc. I don't really understand the last part of your second question "Is the drupal application it's own drupal instance inside of a drupal website (nested drupals?) ?". Drupal is a collection of PHP files on a server that, together with a slew of tables in a database serves request made to it. Multiple Drupal websites (so different PHP files) can reference the same database or parts of it (for example the user table). There's not really an "instance" of a Drupal site, as there's not really an "application". I could of course be too unfamiliar with these terms but I don't think PHP works with "instances" of "applications".

  3. That's a hard problem, afaik Drupal doesn't work with MS SQL, so any connections in that direction you might have to make yourself. I'd also ask around the Drupal forums or on IRC.

Good luck!

兰花执着 2024-08-17 19:25:32

rlb,

我已经使用过相当多的 Drupal,并且拥有丰富的 ASP.NET 经验。您确实需要阅读以理清思路。他们以类似 MVC 的方式使用层,这对于 WebForms 和 WebForms 来说非常陌生。 ASP.NET MVC 开发人员……坦白地说,乍一看似乎很奇怪。

以下是我为了快速获得真正非常好的成绩而所做的一系列事情:

  1. 花 8 美元购买一个像 hostgator 这样的主机,它可以让你安装 Drupal
  2. 获取《Pro Drupal Development for Beginners》这本书……非常好,确实涵盖了很多领域 http://www.amazon.com/Pro-Drupal-Development-Second-Beginning/dp/ 1430209895/ref=sr_1_2?ie=UTF8&s=books&qid=1257545528&sr=8-2
  3. 访问 Drupal 论坛
  4. 准备好做出贡献。 Drupal 有很多功能,但最终最好的方法是成为贡献代码的人。

有许多 IDE 需要考虑,但启动一个文本编辑器应该没问题。

祝你好运。

rlb,

I've done quite a bit of Drupal and have strong ASP.NET experience. You really need to read up to get your mindset straight. They use layers in an MVC-like fashion that is very foreign to WebForms & ASP.NET MVC developers ... and quite frankly at first seems odd.

Here's a list of things I did to get really, really good quickly:

  1. Get a host like at hostgator for $8 which will let you install Drupal
  2. Get the book Pro Drupal Development for Beginners ... excellent and really covers a lot of areas http://www.amazon.com/Pro-Drupal-Development-Second-Beginning/dp/1430209895/ref=sr_1_2?ie=UTF8&s=books&qid=1257545528&sr=8-2
  3. Get on the Drupal forums
  4. Be ready to contribute. Drupal has a lot of features, but in the end the best way is to be someone who contributes code back

There are a number of IDEs to consider, but to start a text editor should be fine.

Good luck.

抠脚大汉 2024-08-17 19:25:32

这里有一些很好的答案,所以我只填写一些简短的项目。

1 - Learning Drupal: Pro Drupal Development 是这方面最好的书。进入问题队列并与开发人员互动是熟悉细节的一种方法。您关于表单的问题与 Drupal 如何处理表单有关。 Drupal 中的 FAPI 非常强大,可以保护您免受安全漏洞的影响。另外 api dot Drupal dot org 是代码文档记录的地方,尽管其他地方也有文档。谷歌是你的朋友。 (在 Drupal 站点本身上,使用本机搜索来获取分面结果。)

2 - 这是用户权限问题。您可以根据内容类型限制创建和编辑权限。对于访问控制(读取),您将需要使用众多模块之一进行访问控制。这实际上取决于您的用例。

3 - Drupal 对 MySQL 拥有最多的社区支持,但人们也在 MS SQL 上运行 Drupal。在 Drupal 7 中,您可能会看到更多对非 MySQL 的支持,因为该版本引入了数据库抽象。

也许最糟糕的事情就是钻空子。了解 Drupal 基础知识(管理和编码)的来龙去脉确实值得,这样您才能真正利用 Drupal 带来的强大功能。

如果您正在寻找模块,http://drupalmodules.com 就是您的朋友。 ;)

Some good answers here, so I'll just fill in some brief items.

1 - Learning Drupal: Pro Drupal Development is the best book for this. Getting into the issue queues and interacting with developers is a way to get familiar with specifics. Your question about forms relates to how Drupal handles forms. The FAPI is pretty robust in Drupal, and protects you from security gaffes. Also api dot Drupal dot org is where the code is documented, though there are docs elsewhere. Google is your friend. (On the Drupal site itself, use the native search to get faceted results.)

2 - This is a user permissions issue. You can limit creation and editing permissions based on content type. For access control (read), you will want to use one of the many modules for access control. It really depends upon your use case.

3 - Drupal has the most community support for MySQL, but people run Drupal on MS SQL as well. In Drupal 7, you will likely see much more support for non-MySQL as this release introduces database abstraction.

Probably the worst thing to do is hack around the margins. It really pays to learn the ins and outs of the Drupal basics -- administration and coding -- so that you can truly leverage the power Drupal brings to the table.

And if you're hunting for modules, http://drupalmodules.com is your friend. ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文