Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP > PHP Application Design
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Mar 4, 2006, 12:44   #1
Ezku
SitePoint Guru
 
Join Date: May 2005
Location: Finland
Posts: 609
Zend Framework

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>';
}
Ezku is offline   Reply With Quote
Old Mar 4, 2006, 12:53   #2
Ezku
SitePoint Guru
 
Join Date: May 2005
Location: Finland
Posts: 609
My own thoughts? Interesting. Definitely interesting. Its previewness is rather evident, though. The manual says nothing of Controller, for instance, but the package is still provided with the framework download. There's Zend_Controller, Zend_Controller_Front, Zend_Controller_Dispatcher, Zend_Controller_Router...
Ezku is offline   Reply With Quote
Old Mar 4, 2006, 13:06   #3
logitron
SitePoint Zealot
 
logitron's Avatar
 
Join Date: Feb 2006
Posts: 143
Hmm...looks like nothing more but a bunch of PHP classes. :-P
logitron is offline   Reply With Quote
Old Mar 4, 2006, 13:17   #4
akrabat
SitePoint Zealot
 
Join Date: Oct 2004
Location: Worcester
Posts: 138
I agree that it's interesting. Not sure what happened to "extreme simplicity" though as the front controller at least is pretty standard from what I can tell...

As I said on the other thread, I've played a bit with the Front Controller and it fits together fairly easily (I wrote up my first attempt at www.akrabat.com). The FC is setup by default so that you have a controller class with functions for each action. i.e. http://localhost/blog/view ends up at BlogController::view(). I haven't yet worked out how the Zend_View class fits in though...

It's not a lot different from the way I've been playing with a front controller recently. The question is what do I gain by using the ZF one rather than my own. It's not like there's so much code in a FC that maintenance will be a big issue...

As Selkirk noted, the active record is missing from the download which is a shame as I want to poke around that bit! It's a certainty that I'd rather use someone else's orm because there's more obviously upgrades and enhancements that can be shared.
akrabat is offline   Reply With Quote
Old Mar 4, 2006, 13:23   #5
McGruff
simple tester
 
McGruff's Avatar
 
Join Date: Sep 2003
Location: Glasgow
Posts: 1,680
Quote:
Originally Posted by Ezku
I thought a thread of its own would be in order.
A whole series of topics, probably. I think there will be a lot to discuss and the framework will be bound to evolve once more pairs of eyes get a chance to assess it.

I've only had a quick glance at a few classes so far. InputFilter seems to stack up every validation rule under the sun in separate methods of a single class. Perhaps it would be better to have a look at the Specification pattern, discrete Rule classes and policies.

(PS: Jason's Php Architect's Guide to Design Patterns has a section devoted to this for anyone interested in learning more).
McGruff is offline   Reply With Quote
Old Mar 4, 2006, 13:31   #6
Ren
SitePoint Guru
 
Ren's Avatar
 
Join Date: Aug 2003
Location: UK
Posts: 931
ZSearch is quite good so far, indexed 5,200 documents, and seems to be searching fine, thou lacking a cache for the results, which would've been very useful.
Ren is offline   Reply With Quote
Old Mar 4, 2006, 14:03   #7
dreaz
Where's my title at?
 
dreaz's Avatar
 
Join Date: Apr 2004
Posts: 249
Anyone else can't get the demos to work?

All web services demos:
Quote:
Fatal error: Undefined class constant 'HOST_ALLOW_DNS'
ZSearch:
Quote:
Fatal error: Exception thrown without a stack frame in Unknown on line 0
I have both incubator and library on my include_path and I'm using PHP 5.0.5
dreaz is offline   Reply With Quote
Old Mar 4, 2006, 14:16   #8
Dr Livingston
Non-Member
 
Join Date: Jan 2003
Posts: 5,799
Umm...

Had a look through the download earlier and there is one thing missing from it... Where are the unit tests?
Dr Livingston is offline   Reply With Quote
Old Mar 4, 2006, 14:20   #9
thr
SitePoint Guru
 
thr's Avatar
 
Join Date: Jun 2003
Location: Sweden
Posts: 664
Kinda disapointed that the put the ZendDBDataObject (thier AR implementation) in the Manual, but didn't put it in the .tar.gz file ;/. Other then that it looks quite nice, much better then your avarage pvp framework.
thr is offline   Reply With Quote
Old Mar 4, 2006, 14:23   #10
Selkirk
SitePoint Guru
 
Join Date: Nov 2002
Posts: 845
Andi responds about Zend_Db_DataObject on the mailing list:
Quote:
This is actually some documentation that stuck around from our ActiveRecord implementation. We have currently decided to first focus on table and row gateway modules and re-evaluate whether we need an additional layer on top of that which would be Zend_Db_DataObject.
Selkirk is online now   Reply With Quote
Old Mar 4, 2006, 15:07   #11
Kings
What a twist!
 
Kings's Avatar
 
Join Date: Jul 2002
Location: The Netherlands
Posts: 1,031
Quote:
Originally Posted by dreaz
Anyone else can't get the demos to work?

All web services demos:


ZSearch:


I have both incubator and library on my include_path and I'm using PHP 5.0.5
To fix the constant not defined problem:

In Zend/Uri/Http.php, on line 373, change Zend_InputFilter to Zend_Filter both times, so that the line becomes:

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

But even so, after that I couldn't get the Zend_Feed object working. Gave me a few other errors.

So far I'm not really impressed with the framework, and it still feels very buggy to me. I couldn't get much working, and even the demos gave problems. But if they work out the problems, it looks to be a really good framework.
Kings is offline   Reply With Quote
Old Mar 4, 2006, 15:11   #12
akrabat
SitePoint Zealot
 
Join Date: Oct 2004
Location: Worcester
Posts: 138
Update on Andi Gutmen's blog: http://andigutmans.blogspot.com/2006...rk-update.html
akrabat is offline   Reply With Quote
Old Mar 4, 2006, 15:35   #13
dreaz
Where's my title at?
 
dreaz's Avatar
 
Join Date: Apr 2004
Posts: 249
Quote:
Originally Posted by akrabat
Even after those updates the demos are completely bugged
dreaz is offline   Reply With Quote
Old Mar 4, 2006, 15:50   #14
Ren
SitePoint Guru
 
Ren's Avatar
 
Join Date: Aug 2003
Location: UK
Posts: 931
Quote:
Originally Posted by Dr Livingston
Umm...

Had a look through the download earlier and there is one thing missing from it... Where are the unit tests?
"I agree. I was actually hoping they will be part of this release.
Must have slipped by." - Andi Gutmans on the framework mailinglist
Ren is offline   Reply With Quote
Old Mar 4, 2006, 16:24   #15
dreamscape
SitePoint Wizard
 
dreamscape's Avatar
 
Join Date: Aug 2005
Posts: 1,080
uh, why did they steal Apple's RSS icon? It's not even that they used Apple's icon as influence for theirs... they blatantly stole it (it matches pixel for pixel). It's not as if freely available to use RSS icons are difficult to come across or it's difficult to make you own.

Ok *maybe* that has nothing to do with the framework, but it gives a really bad impression when companies do things like that. I really lost quite a bit of respect for Zend what I saw that.

How is digital theft "in the true PHP spirit"?


On this framework, I'm not quite sure I see how it is any easier to use than existing, more developed PHP frameworks. Though it's only version 0.1.1, so I'll probably hold off too much experimentation and opinion formulation until its a bit more mature (at least version 1.0).
dreamscape is offline   Reply With Quote
Old Mar 4, 2006, 16:54   #16
Dr Livingston
Non-Member
 
Join Date: Jan 2003
Posts: 5,799
> I'm not quite sure I see how it is any easier to use than existing, more developed PHP frameworks.

At the moment nope, I agree with you, but that isn't the issue, is it? What other PHP framework has the Zend name attached to it?

From a business point of view, considering that how far Zend has come, and importantly, where they're going, the framework in time will not so much carry it's self, but the brand will; That is how I look at it anyways.

Something else to do forget is the kind of influence that Zend can put across to get the right kind of people to develop and continue to develop the framework, when push comes to shove

There is power in influence as the saying goes. Individuals, businesses, even goverments have fallen simply because of influence.
Dr Livingston is offline   Reply With Quote
Old Mar 4, 2006, 21:13   #17
warjockey
SitePoint Addict
 
warjockey's Avatar
 
Join Date: Apr 2002
Posts: 285
pretty good,
if anything it will attract developers from java and .net to php.

Will I use it? if I get bored one day yes, but I already have some of these classes done myself so I don't really feel like setting up the whole thing especially on a host.
warjockey is offline   Reply With Quote
Old Mar 5, 2006, 00:58   #18
Nick Carlson
SitePoint Guru
 
Nick Carlson's Avatar
 
Join Date: Aug 2003
Location: Denver
Posts: 757
Wow, it's amazing how such a large organization can produce such a large POS.

If you are looking for a PHP framework, look no further: CakePHP - FAQ
Nick Carlson is offline   Reply With Quote
Old Mar 5, 2006, 01:06   #19
Dr Livingston
Non-Member
 
Join Date: Jan 2003
Posts: 5,799
Wow...

That's very constructive of you to make that comment, not

I certainly can't comment on ZF as it's too early but I would wager a bet that for the long haul, Zends framework has more potential that Cake PHP has.
Dr Livingston is offline   Reply With Quote
Old Mar 5, 2006, 01:52   #20
thr
SitePoint Guru
 
thr's Avatar
 
Join Date: Jun 2003
Location: Sweden
Posts: 664
Quote:
Originally Posted by optimus prime
Wow, it's amazing how such a large organization can produce such a large POS.
First of all, this is a preview release (while I do think that some parts are not that good, there are some gems in there). Second of all, the PHP Collaboration Project (which ZF is a part of as far as I can see...) is suported by IBM, Oracle and some others... CakePHP is supported by.. eh... hmm..*looks at black void*
thr is offline   Reply With Quote
Old Mar 5, 2006, 02:29   #21
akrabat
SitePoint Zealot
 
Join Date: Oct 2004
Location: Worcester
Posts: 138
Quote:
Originally Posted by optimus prime
Wow, it's amazing how such a large organization can produce such a large POS.
I'm sure that they would appreciate more constructive criticism. Certainly, they are actively responding to comments on the mailing list and the phrase "fixed in SVN" is turning up frequently.

So far, I'm quite impressed with the way the mailing list is developing as it is looking like a community might develop nicely.

The decision to start with Table and Row Gateways is interesting as it leaves it open for putting in a more "complex" orm should you need it.
akrabat is offline   Reply With Quote
Old Mar 5, 2006, 02:36   #22
thr
SitePoint Guru
 
thr's Avatar
 
Join Date: Jun 2003
Location: Sweden
Posts: 664
Quote:
Originally Posted by akrabat
So far, I'm quite impressed with the way the mailing list is developing as it is looking like a community might develop nicely.
Yes, the mailinglist sure is active (and good)

Quote:
Originally Posted by akrabat
The decision to start with Table and Row Gateways is interesting as it leaves it open for putting in a more "complex" orm should you need it.
I agree on this, but I have to say that it feels quite strange to ship a framework with "just" Table/Row Gateways.
thr is offline   Reply With Quote
Old Mar 5, 2006, 02:54   #23
paulyG
SitePoint Wizard
 
Join Date: Jan 2004
Location: 3rd rock from the sun
Posts: 1,005
Quote:
So far, I'm quite impressed with the way the mailing list is developing as it is looking like a community might develop nicely.
Zend framework firming up, an active Zend community and the eclipse plugin looming.. Hmmm... maybe its time to get myself Zend certified now, before they start extending the exam.
paulyG is offline   Reply With Quote
Old Mar 5, 2006, 03:37   #24
Edman
SitePoint Evangelist
 
Join Date: Apr 2005
Posts: 492
Can't see it being worthwile to someone who's already a professional developer, at least not at this stage.
Edman is offline   Reply With Quote
Old Mar 5, 2006, 03:39   #25
thr
SitePoint Guru
 
thr's Avatar
 
Join Date: Jun 2003
Location: Sweden
Posts: 664
Quote:
Originally Posted by Edman
Can't see it being worthwile to someone who's already a professional developer.
Except for the fact that it's the first MVC framework for php that's backed by Zend, and that guarantess you (almost) that the project won't stop in 1 month after you invested all your business using the framework, which could happend with "hoby" projects.
thr is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 02:42.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved