I’ve been doing a lot of work with Zend Framework the past few days. One of the things that’s been bugging me is how much code I have in my controllers to save data. The validation and filtering is handled by the Zend_Form object, but the forms don’t always match the models as far as fieldnames and other information, so I don’t just want to throw a form result set at a Zend_Db_Table_Row and let it figure things out.
Result: I taught my forms to know how to fill and save themselves. They use the model layer to accomplish this, but work mostly by extending the normal Zend_Form with a ‘populate’ and a ’save’ method. The populate method can be static. It takes a primary key and returns an array that can be used to populate the form. The save method is not static, and depends on the form already being populated and having been validated.
As a quick disclaimer, I by no means would say that this is the best practice for this kind of thing … and this code is quickly hacked up edited code that I put together from what I’m really doing. No guarantees that it works … however, the theory works for me!
One of the websites I’ve done consulting work on, BookGlutton, has been nominated for a Webby Award. Congratulations to Travis and Aaron!
The majority of the site was developed using Symfony, XMPP, and the blog is Wordpress. I helped write a bunch of the user account management …
You might be wondering what these three things have to do with one another.
The basic gist is that I’m trying to use the Wordpress 2.5 RSS widget to read in my Google Reader ’shared items’ feed. Google Reader will publish your shared items in an Atom RSS feed. For a sample, you can see mine here.
The RSS feed is all fine and dandy. It’s valid, it’s namespaced correctly, and it’s got all but one of the required elements. The problem comes when you try to parse it with Magpie. Inside the “entry”, there’s a “title”. There’s also a “source”. The “source” has a “title” attribute as well.
Great little tutorial on getting started with Zend Framework and the Doctrine ORM. It only provides simple usage, but it’s a good place to start. Doctrine is an Object Relational Model library for PHP >=5.2 that supports all kinds of nifty features like Migrations.
Let’s say you’re scanning a website for it’s feeds using Zend_Feed::findFeeds($URL). The function looks at a website, and checks for the link tags in the head part of the document that would indicate that it has feeds. Then it returns an array of those feeds.
Now, for the sake of …
If you use vim and develop in PHP, you need these tips.
If you’re on a Mac like I am but prefer command-line vim in a terminal window, you can download an updated version of VIM and then just symlink /usr/bin/vim to the bundle in the /Applications directory, and it’ll run …
Here’s a few links talking about the PHP opcode cache, which came out of a discussion on the Zend Framework mailing list about whether or not Zend Framework benefits from APC and other Opcode Caches.
http://pooteeweet.org/blog/538
http://t3.dotgnu.info/blog/php/demystifying-autofilter.html
The general gist of things is if you have a hierarchy of functions like Zend Framework does and code in a one-class-per-file style and include conditionally (based upon autoload and other mechanisms like includes inside conditionals), then you may take a corresponding performance hit. However: This should be fixed in PHP 5.3.
When I first started doing PHP back in 2000, PHP4 was brand new. I did some extensive testing to figure out the best way to echo strings. It turned out that the best way was using single quotes, because otherwise the PHP parser parsed the string for variables.
In modern times, …
Getting this error?
dyld: NSLinkModule() error
dyld: Library not loaded: /Users/severin/Dev/Projects/MAMP_1.7_src/lib/libltdl.3.dylib
Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/mcrypt.so
Reason: image not found
Trace/BPT trap
If you enjoy the content, consider subscribing to the feed(s).
4 Comments