今天才知道這個消息,1.5 做了很多改動,包括路由部分的大小寫解析方式也同以前 1.0x 不同。新功能對于只用 Zend Framework 開發普通網站的人來說并不是十分要緊。Zend_Form 和 Zend_Layout 反而會增加頁面編輯的難度。 * New Zend_Form component with support for AJAX-enabled form elements * New action and view helpers for automating and facilitating AJAX requests and alternate response formats * LDAP, Infocard, and OpenID authentication adapters * Support for complex Lucene searches, including fuzzy, date-range, and wildcard queries …
Category Archives: PHP
PHP 生成 PDF 的又一个选择——TCPDF
http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf 今天在 sourceforge 上看到了 2.7.001 放出了。看了一下例子,貌似很好用的样子。 安装也很简单,关键就是配置 config/tcpdf_config.php 文件中的 K_PATH_MAIN 和 K_PATH_URL,分别设置为物理路径和 URL 地址。
在 Windows 下使用 Notepad++ 和 xdebug 调试 php 脚本
介绍 Notepad++ 是开放源代码的可替代记事本的编辑器。它运行于 MS Windows 环境,支持多种编程语言。可以浏览 http://notepad-plus.sourceforge.net/ 了解更多相关信息。 Xdebug 是 php 的一个扩展,它提供了对 php 脚本进行除错、追踪、检查的各种功能。可以浏览 http://xdebug.org 了解更多相关信息。
Zend_Mail 发送邮件后提示 Fatal Error
这实际上是由于 PHP 不允许在析构函数中抛出异常造成的,关于这个 issue 我已经提交到 issues 上: http://framework.zend.com/issues/browse/ZF-2534 暂时没有想到好的解决方法。通常执行到析构函数时,邮件已经正确发出。所以最不济的方法就是用try…catch… 捕获异常,并忽略掉。 如下: public function __destruct() { try { if ($this->_connection instanceof Zend_Mail_Protocol_Smtp) { $this->_connection->quit(); $this->_connection->disconnect(); } catch(Zend_Exception $e) { } }
Zend_Mail 中文主题编码后超过74个字节,主题乱码的 Bug
Zend_Mail 中文主题乱码的原因主要是在编码后超长内容的设置上出现问题。 已经提交到 issues 上了: http://framework.zend.com/issues/browse/ZF-2532 如果有朋友遇到主题乱码,可以尝试使用更短的主题。或者使用我在 issrues 上提到的方法临时解决一下。 据我所知,这个 bug 在 1.5 的 perview 版本中依然存在。
Zend Framework 1.5 快要出来了
看到邮件列表上说,于 1 月 22 日冻结代码,计划 1 月 24 日正式发布。 增加了不少新的功能,正式发布的时候还可能有更多的一些功能: * Zend_Auth_Adapter_Ldap * Zend_Build/Zend_Console * Zend_Controller additional action helpers * ContextSwitch and AjaxContext * Json * AutoComplete * Zend_Form * Zend_InfoCard * Zend_Layout * Zend_OpenId * Zend_Search_Lucene improvements: * wildcard search * date range search * fuzzy search * Lucene 2.1 index file format support …
ninny project 单元测试框架使用说明
系统运行要求 PHPUnit 3.1.x PHPUnit 的安装 参考:http://www.phpunit.de/pocket_guide/3.1/en/installation.html 建议使用 Pear 方式安装。 Pear 包的安装请参考http://pear.php.net/manual/en/installation.php 测试用例的编写 参考:http://www.phpunit.de/pocket_guide/3.1/en/writing-tests-for-phpunit.html 应注意,在本框架使用中实际无需在测试用例加载任何文件。 配置文件的设置 <?xml version=’1.0′ encoding=’UTF-8′ ?> <AllTests> <TestSuite> <name>FoobarTest</name> <require>AnotherFoobar.php</require> </TestSuite> <Test> <class>Foo_Bar_AllTest</class> <method>suite</method> <require>/home/foo/bar/AnotherLib.php</require> </Test> </AllTests> TestSuite? 标签指定需要加载的单元测试用例。name 标签指定测试用例名(类名)。 Test 为一组单元测试用例。class 标签指定测试用例组类名,method 标签指定该类返回 PHPUnit_Framework_TestSuite 实例的类方法。 类名的命名应遵从 Zend Framework 的命名规则,即下划线分隔文件路径作为类名。如:类文件存放于 Foo/Bar/AllTest.php,则类对应为 class Foo_Bar_AllTest {…}。 测试用例和测试用例组都将自动加载。保存于 include path 下,符合 Zend Framework 类命名规范的类也都将自动加载(使用 Zend_Loader::registerAutoload() …
在 Zend Framework 中使用 Jquery 的 ajax 功能
发现不少人对此有迷惑,所以有通常的做法:设置 noViewRender,然后将 ajax 调用时的返回数据直接输出于 controller 中。 个人以为,这种做法不是不可以。但是在 Zend Framework 中这样使用,就有违 MVC 的分离原则。controller 不应该区分显示到客户端的是页面还是 json 或者 xml。 下面是我的做法,仅供参考。部分调用了 ninny project 中封装的功能凑合看吧: ———————–view script: index.php————————— <?php echo $this->jquery();?> <script language="javascript"> // jquery ajax 的 json $().ready( function(){ $("#load").click( function() { $.getJSON("/foobar/index/ajax",function(data){ $("#title").html(data.title); content = ""; $.each(data.content, function(i, line){ content += line + "<br/>"; }); $("#content").html(content); }); }); …
An issue about Zend_Translate_Adapter
My codes is: public function testGetTextTw() { $t = new Zend_Translate(‘gettext’, ‘./_locale/’, ‘zh_TW’); $this->assertEquals(‘n2’, $t->_(‘New’)); } public function testGetTextCn() { $t = new Zend_Translate(‘gettext’, ‘./_locale/’, ‘zh_CN’); $this->assertEquals(‘n1’, $t->_(‘New’)); } But, the testGetTextCn() go into fail: expected string ‘n1’ but got string ‘n2’. So, I read the codes in Zend_Translate_Adapter::__construct(). the param …
在PHP中使用Lucene 讲义幻灯、代码示例
下载 9月2日的讲义幻灯和代码示例。 在线演示:www.i-fang.com/php/lucene4php/search.php 内容如下: