I thought a thread of its own would be in order.
Quote:
Zend Framework Website Launches
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.
This site will be the home to project related information such as downloads, the manual, and project updates. We will also put up instructions next week for how to access the Subversion repository so that you can play around with code as it's being developed (for better or for worse).
The first preview release of the Zend Framework is available for download.
|
Contained modules (of varying completeness):
- 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
Check out some snippets from the
included manual:
Zend_Db_DataObject
PHP Code:
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
PHP Code:
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
PHP Code:
// Retrieve a value:
$phpNative = Zend_Json::decode($encodedValue);
// Encode it to return to the client:
$json = Zend_Json::encode($phpNative);
Zend_Mail
PHP Code:
require_once 'Zend/Mail.php';
$mail = new Zend_Mail();
$mail->setBodyText('This is the text of the mail.');
$mail->setFrom('somebody@example.com', 'Some Sender');
$mail->addTo('somebody_else@example.com', 'Some Recipient');
$mail->setSubject('TestSubject');
$mail->send();
Zend_Service_Rest
PHP Code:
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 '<p>An error occurred</p>';
}
} catch (Zend_Exception $e) {
echo '<p>An error occurred (' .$e->getMessage(). ')<p>';
}