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_Db_DataObject
-
require_once('ZActiveRecord/ZActiveRecord.php');
-
-
// Create a ZDBAdapter for ZActiveRecordBase.
-
$db = new ZDBAdapterMySQL(array('host' => 'localhost',
-
'username' => 'user',
-
'password' => 'password',
-
'database' => 'test'));
-
-
ZActiveRecord::setDatabaseAdapter($db);
-
-
class Person extends Zend_Db_DataObject {}
-
-
/**
-
* Calling the save() method will successfully INSERT
-
* this $person into the database table.
-
*/
-
$person = new Person();
-
$person->nameFirst = 'Andi';
-
$person->nameLast = 'Gutmans';
-
$person->favoriteColor = 'blue';
-
$person->save();
Zend_Db_Select
-
require_once 'Zend/Db.php';
-
$params = array (
-
'adapter' => 'pdoMysql',
-
'host' => '127.0.0.1',
-
'username' => 'malory',
-
'password' => '******',
-
'dbname' => 'camelot'
-
);
-
-
$db = Zend_Db::factory($params);
-
-
$select = $db->select();
-
// $select is now a Zend_Db_Select_PdoMysql object
-
-
// SELECT *
-
// FROM round_table
-
// WHERE noble_title = "Sir"
-
// ORDER BY first_name
-
// LIMIT 10 OFFSET 20
-
//
-
-
// you can use an iterative style...
-
$select->from('round_table', '*');
-
$select->where('noble_title = ?', 'Sir');
-
$select->order('first_name');
-
$select->limit(10,20);
-
-
// ...or a "fluent" style:
-
$select->from('round_table', '*')
-
->where('noble_title = ?', 'Sir')
-
->order('first_name')
-
->limit(10,20);
-
-
// regardless, fetch the results
-
$sql = $select->__toString();
-
$result = $db->fetchAll($sql);
-
-
// alternatively, you can pass the $select object itself;
-
// Zend_Db_Adapter is smart enough to call __toString() on the
-
// Zend_Db_Select objects to get the query string.
-
$result = $db->fetchAll($select);
Zend_Json
-
// Retrieve a value:
-
$phpNative = Zend_Json::decode($encodedValue);
-
-
// Encode it to return to the client:
-
$json = Zend_Json::encode($phpNative);
Zend_Mail
-
require_once 'Zend/Mail.php';
-
$mail = new Zend_Mail();
-
$mail->setBodyText('This is the text of the mail.');
-
$mail->setFrom(<a href="mailto:'somebody@example.com'">'somebody@example.com'</a>, 'Some Sender');
-
$mail->addTo(<a href="mailto:'somebody_else@example.com'">'somebody_else@example.com'</a>, 'Some Recipient');
-
$mail->setSubject('TestSubject');
-
$mail->send();
Zend_Service_Rest
-
require_once 'Zend/Service/Rest.php';
-
-
try {
-
$rest = new Zend_Service_Rest();
-
-
$rest->setURI('http://example.org');
-
-
// Returns a Zend_HttpClient_Response Object
-
$response = $rest->restGet('/services/rest', 'foo=bar&baz=bat');
-
-
if ($response->isSuccessful()) {
-
echo $response->getBody();
-
} else {
-
echo 'An error occurred
-
';
-
}
-
} catch (Zend_Exception $e) {
-
echo 'An error occurred (' .$e->getMessage(). ')';
-
}
作者: Volcano 发表于March 5, 2006 at 10:07 am
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).
King 于 2006-03-06 @ 12:39:50 留言 :
晕,怎么我搜缴不出来,volcano 能提供一下具体下载地址吗?
King 于 2006-03-06 @ 13:19:00 留言 :
呵呵,看到了,在页底有链接
volcano 于 2006-03-06 @ 13:20:24 留言 :
在这里:
http://framework.zend.com/download
volcano 于 2006-03-07 @ 10:26:18 留言 :
陈泽对zend_view的部分翻译
http://www.surfchen.org/?p=162
volcano 于 2006-03-07 @ 17:30:09 留言 :
php | architect上的zend framework教程
http://www.phparch.com/zftut/
volcano 于 2006-03-15 @ 08:47:30 留言 :
php | architect上的zend framework教程更新,支持0.1.2版本,下面是教程的相关代码
http://brainbulb.com/zend-framework-tutorial.tar.gz
volcano 于 2006-03-16 @ 09:49:55 留言 :
Zend Framework体验(一)初识
http://bbs.chinaunix.net/viewthread.php?tid=717856&extra=page%3D1