Home php教程 php手册 Delphi for PHP 评测

Delphi for PHP 评测

Jun 06, 2016 pm 07:56 PM
delphi for p php Review

Delphi for PHP 评测 Haohappy haohappy AT msn.com http://blog.csdn.net/haohappy2004 为书写方便,下面将 Delphi for PHP 简写为D4P。 其实现在写这篇评测稍早了一些,因为这个IDE以及使用的开发框架Vcl for PHP都才刚推出不过一个月。 首先请先回顾一下

Delphi for PHP 评测
Haohappy  haohappy AT msn.com
http://blog.csdn.net/haohappy2004

为书写方便,下面将Delphi for PHP简写为D4P。

其实现在写这篇评测稍早了一些,因为这个IDE以及使用的开发框架Vcl for PHP都才刚推出不过一个月。

首先请先回顾一下关于三种主流WEB架构的思考 一文所说的三种WEB开发方式,使用D4P开发是典型的第三种方式,就是IDE+基于控件、事件驱动的开发框架。

我根据D4P的DEMO,设计了两个程序,一个是普通的表单提交-返回程序,然后我所熟悉的QuickForm进行了对比;另一个是数据库程序,就是查询一个MySQL表,然后返回,另外试用DataGrid列出数据。

在写测试程序的过程中,除了熟悉和体验一下IDE的使用,其实我更感兴趣的是Delphi for PHP这个IDE所采用的PHP开发框架――Vcl for PHP(http://www.qadram.com/vcl4php/)。在我使用D4P之前,我就猜测Codegear在易用性上一定不错,这个猜测得到了证实。但是Vcl for PHP是否是一个优秀的PHP框架? 如果没有优秀的开发框架,不能保证程序的质量和效率,那么光靠个优秀的IDE,开发出来的程序一定是中看不中用,没人敢用。

基于这个想法,我认真研究了一下VCL for PHP(简称为V4P)。这个框架2007年3月27才开源的,也就是说开源不到一个月。框架文件位于C:/Program Files/CodeGear/Delphi for PHP/1.0/vcl目录,或者你也可以在http://www.qadram.com/vcl4php/网站上下载到。

我们可以看到,V4P使用了很多我们熟悉的PHP开源类库,例如ADODB、Smarty、Xajax、Nusoap等等,还使用了qooxdoo这个JS GUI工具包。也可以看到一些似乎还未完成的类库,如对Google Map的调用(见vcl/google目录),对PHPBB论坛的调用等。这下你明白了吧,为什么D4P这么强大,呵呵,因为它站在巨人的肩膀之上啊。不过这也带来了一个问题,太依赖别人的类库,缺乏自主性,对于代码质量带来了不可控因素。

对于第一个测试程序,很简单,就是一个表单提交数据,然后返回响应。大家可以自己参照Demo来写,我测试了一下效率,大概执行时间在0.5秒左右,嗯,算是非常慢。

对于第二个测试程序,也就是数据库操作程序,是我比较重视的,下面来详细介绍一下。

D4P目前支持MySQL和Interbase两种数据库。我打开D4P的安装目录看了一下,原来数据库访问层使用的是ADODB(http://adodb.sourceforge.net)这个开源类库。也就是说理论上将来D4P可能支持非常多的数据库,因为ADODB实在太强大(这里是ADOdb支持的所有数据库:http://phplens.com/adodb/supported.databases.html)。

D4P提供了五种数据库访问控件(Data Access:Datasource,Database,Table,Query,StorProc—数据源、库、表、查询、存储过程)和三种数据库控制控件(DBGrid,DBPaninator,DBRepeater—表数据列表、分页、表数据或记录集列表)。

DBGrid的设计还是很精巧的,前端采用了AJAX,显示很漂亮,还可以直接更新。但显示速度较慢。老实说这样一种东西对于管理后台数据库似乎中看不中用,如果是数据库管理,我们还是使用熟悉的更为强大的PHPMyAdmin吧;如果是提供给用户的管理页面,我们要定制很多页面效果,DBGrid又不满足要求(太复杂了,而且都封装起来了,修改效果不如自己写)。用于给客户作展示倒是挺适合的。

Delphi for PHP 评测

我们再来测试一下代码的执行速度。任务很简单,我们从两个表中分别读取30条记录,然后分别两个生成DataGrid:

测试代码非常简单:

<span><?php </span></span>
<span>$time_start </span>
<span>= </span><span>microtime_float</span><span>(); </span>
<span>        </span>
<span>//Includes </span>

<span>        </span>
<span>require_once(</span><span>"vcl/vcl.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"forms.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"dbgrids.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"dbctrls.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"db.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"dbtables.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"extctrls.inc.php"</span><span>); </span>
<span>        </span>
<span>use_unit</span><span>(</span><span>"stdctrls.inc.php"</span><span>); </span>

<span>$time_start2 </span><span>= </span><span>microtime_float</span><span>(); </span>

<span>        </span>
<span>//Class definition </span>
<span>        </span>
<span>class </span><span>Unit2 </span><span>extends </span><span>Page </span>
<span>        </span>
<span>{ </span>
<span>               public </span>
<span>$DBGrid2 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$dsfeedentry1 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$tbfeedentry1 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$Query1 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$DBGrid1 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$dsarticle1 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$dbhappycms21 </span><span>= </span><span>null</span><span>; </span>
<span>               public </span>
<span>$tbarticle1 </span><span>= </span><span>null</span><span>; </span>

<span>        } </span>

<span>        global </span>
<span>$application</span><span>; </span>

<span>        global </span>
<span>$Unit2</span><span>; </span>

<span>        </span>
<span>//Creates the form </span>
<span>        </span>
<span>$Unit2</span><span>=new </span><span>Unit2</span><span>(</span><span>$application</span><span>); </span>

<span>        </span>
<span>//Read from resource file </span>
<span>        </span>
<span>$Unit2</span><span>-></span><span>loadResource</span><span>(</span><span>__FILE__</span><span>); </span>

<span>        </span>
<span>//Shows the form </span>
<span>        </span>
<span>$Unit2</span><span>-></span><span>show</span><span>(); </span>

<span>        function </span>
<span>microtime_float</span><span>(){ </span>
<span>                list(</span>
<span>$usec</span><span>, </span><span>$sec</span><span>) = </span><span>explode</span><span>(</span><span>" "</span><span>, </span><span>microtime</span><span>()); </span>
<span>                return ((float)</span>
<span>$usec </span><span>+ (float)</span><span>$sec</span><span>); </span>
<span>        } </span>

<span>$time_end </span><span>= </span><span>microtime_float</span><span>(); </span>
<span>$time_lib </span><span>= </span><span>$time_start2</span><span>-</span><span>$time_start</span><span>; </span>
<span>$time_total </span><span>= </span><span>$time_end </span><span>- </span><span>$time_start</span><span>; </span>

<span>echo </span>
<span>"Loaded libs in $time_lib seconds and all processed in  $time_total seconds"</span><span>; </span>
<span>?></span>

输出结果:

Delphi for PHP 评测

Loaded libs in 1.1935691833496 seconds and all processed in 2.1492249965668 seconds

结果告诉我们:读取两个表并且生成DataGrid总共花费了2.14秒,其中加载公用类库用了1.2秒。

我用PHP程序员最常用的数据表读取及输出结果的代码进行同样功能的代码重写,即用两个mysql_query(‘SELECT * FROM table limit 0,30’)得到结果并用while循环输出,消耗时间为:
All processed in 0.31938099861145 seconds

0.3秒对2.1秒,相差7倍,可见D4P的DataGrid效率相当低。注意这是测试的是服务器端数据查询的执行效率,实际上在浏览器端的显示也有明显延迟,可能qooxdoo的效率也不高。

D4P除了有自带的基于qooxdoo的DataGrid,还可以与PEAR的DataGrid直接集成,就是一个正常的HTML表格界面,相对比较容易扩展。

其它:

小结一下:

D4P的优点:

  • 界面清爽漂亮,IDE速度较快。操作简便,继承了Delphi的传统。
  • 控件相当齐全,所有的表单和常见的HTML控件,还有不少特色组件,比如HTML在线编辑器、进度条、日期选择器、日历、树状菜单等等。还有数据库和WEBServices控件等。可以满足大部份情况下设计的需要。
  • 代码可复用性高。

D4P的缺点:

  • 只支持Windows平台;光是这一点,就无法与ZDE相抗衡,不过在中国问题不大,因为在中国大部份人都在Windows下开发项目,在Linux下布署。
  • 生成的代码执行效率不高。

这是个主要缺陷,具体看上面的测试数据。如果是“展示型”的站点,例如门户网站的新闻频道,肯定不可能用这样的框架来开发。因为我们要对服务器端的脚本和生成的HTML/JavaScript都要精确控制,减少效率和带宽上的浪费。

将来我也许会拿D4P来开发OA之类的企业内部应用。这种项目界面控件比较多,需求比较复杂,变化比较多,但系统负载不大,对效率要求不高。

  • VCL for PHP以大量开源类库为基础,代码质量不能保证完全可控制。

Vcl for PHP无法对其使用的开源类库的代码作统一的质量控制,所以我对这样一个工具执怀疑态度。我喜欢程序的每一部份都是“可控”的,过多的封装和过多的依赖其它第三方类库让我对其内部产生不信任。

当然,Vcl for PHP作为开源项目才诞生一个月,还有很大发展空间,让我们过段时间再来关注一下,也许到时会有惊喜出现。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles