Zend Releases Zend Framework Preview Release

Zend发布了Zend Framework的第一个预览版本:

We are glad to finally unveil the Zend Framework project. We have worked hard in the past few months with our partners and the community to get to this stage. We believe the Zend Framework can already be of great use to PHP developers, although we still have a lot of work ahead of us.

他们为此新建了一个窝点framework.zend.com,可以在此搜缴出这个framework的下载,详细文档,FAQ等等.且让俺来试试这个php的第一个官方开发框架....

Zend Framework is a high quality and open source framework for developing Web Applications and Web Services. Built in the true PHP spirit, the Zend Framework delivers ease-of-use and powerful functionality. It provides solutions for building modern, robust, and secure websites.

后记:运行其中的一个demo: demos\Zend\Feeds,报错(原因是library\Zend\InputFilter.php未定义类常量HOST_ALLOW_DNS):

Fatal error: Undefined class constant 'HOST_ALLOW_DNS' in D:\xampp\htdocs\ZendFramework-0.1.1\library\Zend\Uri\Http.php on line 373

显然预览版比较失败~~

sitepoint论坛上看到的更多介绍:
http://www.sitepoint.com/forums/showthread.php?t=354270

 Zend Framework目前包括下列模块:

  • Zend
  • Zend_Db
  • Zend_Feed
  • Zend_HttpClient
  • Zend_InputFilter
  • Zend_Json
  • Zend_Log
  • Zend_Mail
  • Zend_Mime
  • Zend_Pdf
  • Zend_Search
  • Zend_Service
  • Zend_View
  • 下面是这些模块的一些代码片断:

    Zend_Db_DataObject

    PHP:
    1. require_once('ZActiveRecord/ZActiveRecord.php');
    2.  
    3. // Create a ZDBAdapter for ZActiveRecordBase.
    4. $db = new ZDBAdapterMySQL(array('host'     => 'localhost',
    5.                                 'username' => 'user',
    6.                                 'password' => 'password',
    7.                                 'database' => 'test'));
    8.  
    9. ZActiveRecord::setDatabaseAdapter($db);
    10.  
    11. class Person extends Zend_Db_DataObject {}
    12.  
    13. /**
    14. * Calling the save() method will successfully INSERT
    15. * this $person into the database table.
    16. */
    17. $person = new Person();
    18. $person->nameFirst     = 'Andi';
    19. $person->nameLast      = 'Gutmans';
    20. $person->favoriteColor = 'blue';
    21. $person->save();

    Zend_Db_Select

    PHP:
    1. require_once 'Zend/Db.php';
    2. $params = array (
    3.     'adapter'  => 'pdoMysql',
    4.     'host'     => '127.0.0.1',
    5.     'username' => 'malory',
    6.     'password' => '******',
    7.     'dbname'   => 'camelot'
    8. );
    9.  
    10. $db = Zend_Db::factory($params);
    11.  
    12. $select = $db->select();
    13. // $select is now a Zend_Db_Select_PdoMysql object
    14.  
    15. // SELECT *
    16. //     FROM round_table
    17. //     WHERE noble_title = "Sir"
    18. //     ORDER BY first_name
    19. //     LIMIT 10 OFFSET 20
    20. //
    21.  
    22. // you can use an iterative style...
    23. $select->from('round_table', '*');
    24. $select->where('noble_title = ?', 'Sir');
    25. $select->order('first_name');
    26. $select->limit(10,20);
    27.  
    28. // ...or a "fluent" style:
    29. $select->from('round_table', '*')
    30.        ->where('noble_title = ?', 'Sir')
    31.        ->order('first_name')
    32.        ->limit(10,20);
    33.  
    34. // regardless, fetch the results
    35. $sql = $select->__toString();
    36. $result = $db->fetchAll($sql);
    37.  
    38. // alternatively, you can pass the $select object itself;
    39. // Zend_Db_Adapter is smart enough to call __toString() on the
    40. // Zend_Db_Select objects to get the query string.
    41. $result = $db->fetchAll($select);

    Zend_Json

    PHP:
    1. // Retrieve a value:
    2. $phpNative = Zend_Json::decode($encodedValue);
    3.  
    4. // Encode it to return to the client:
    5. $json = Zend_Json::encode($phpNative);

    Zend_Mail

    PHP:
    1. require_once 'Zend/Mail.php';
    2. $mail = new Zend_Mail();
    3. $mail->setBodyText('This is the text of the mail.');
    4. $mail->setFrom(<a href="mailto:'somebody@example.com'">'somebody@example.com'</a>, 'Some Sender');
    5. $mail->addTo(<a href="mailto:'somebody_else@example.com'">'somebody_else@example.com'</a>, 'Some Recipient');
    6. $mail->setSubject('TestSubject');
    7. $mail->send();

    Zend_Service_Rest

    PHP:
    1. require_once 'Zend/Service/Rest.php';
    2.  
    3. try {
    4.     $rest = new Zend_Service_Rest();
    5.  
    6.     $rest->setURI('http://example.org');
    7.  
    8.     // Returns a Zend_HttpClient_Response Object
    9.     $response = $rest->restGet('/services/rest', 'foo=bar&baz=bat');
    10.  
    11.     if ($response->isSuccessful()) {
    12.         echo $response->getBody();
    13.     } else {
    14.         echo 'An error occurred
    15. ';
    16.     }
    17. } catch (Zend_Exception $e) {
    18.         echo 'An error occurred (' .$e->getMessage(). ')';
    19. }

    作者: Volcano 发表于March 5, 2006 at 10:07 am

    版权信息: 可以任意转载, 转载时请务必以超链接形式标明文章原始出处作者信息及此声明

    Tags: ,,

    8 条评论 »

    1. volcano 于 2006-03-05 @ 20:24:15 留言

      解决办法:

      1. Set your include path to have the “/../ZendFramework-0.1.1/library” directory in it.

      2. In the file “Zend/Http.php” change the line

      “$allow = Zend_InputFilter::HOST_ALLOW_DNS | Zend_InputFilter::HOST_ALLOW_LOCAL;”

      to

      “$allow = Zend_Filter::HOST_ALLOW_DNS | Zend_Filter::HOST_ALLOW_LOCAL;”

      3. In the file “Zend/Filter.php”, at the top add the line “include_once ‘Zend/Filter/Exception.php’;”.

      4. Also in the file “Zend/Filter.php”, comment the line “throw new Zend_Filter_Exception(‘Internal error: IP determination failed’);” (did not look into why — just did it)

      5. Also in the file “Zend/Filter.php”, at the top of function isHostname() just about the line you just commented out — add as the first line “$status = false;” to get rid of the Notice. Pretty sloppy code here if you look everywhere that $status is used (pick 0/1 or true/false).

    2. King 于 2006-03-06 @ 12:39:50 留言

      晕,怎么我搜缴不出来,volcano 能提供一下具体下载地址吗?

    3. King 于 2006-03-06 @ 13:19:00 留言

      呵呵,看到了,在页底有链接

    4. volcano 于 2006-03-06 @ 13:20:24 留言

      在这里:
      http://framework.zend.com/download

    5. volcano 于 2006-03-07 @ 10:26:18 留言

      陈泽对zend_view的部分翻译
      http://www.surfchen.org/?p=162

    6. volcano 于 2006-03-07 @ 17:30:09 留言

      php | architect上的zend framework教程
      http://www.phparch.com/zftut/

    7. volcano 于 2006-03-15 @ 08:47:30 留言

      php | architect上的zend framework教程更新,支持0.1.2版本,下面是教程的相关代码
      http://brainbulb.com/zend-framework-tutorial.tar.gz

    8. volcano 于 2006-03-16 @ 09:49:55 留言

      Zend Framework体验(一)初识
      http://bbs.chinaunix.net/viewthread.php?tid=717856&extra=page%3D1

    RSS 为此帖反馈评论 · 反向跟踪 网站

    留条评论