Magpie 2.0-alpha-alpha-alpha
Probably surprises no one but me, but the work on Magpie has been moving slowly again lately. Rather then continue futzing with it in the rare spare moments, I’m going to push it out in a very raw state, where folks can give some feedback. (and because folks keep asking about it) This is a preview release, very alpha.
Alpha
Alpha means its broken, there are missing features (many of which are actually in the current Magpie 0.7x releases), and stuff will change. Whether you find that exciting or off-putting is a personal thing.
Getting Started
So um, yeah, as of yet no documentation. That said I’ve included the classic magpie_simple.php
script, unchanged except for the require statement. For really simple scripts that is all that is required.
Grab the current code, Magpie 2.0-alpha-PR1. This isn’t its final home, but I am taking this opportunity to finally break free of Sourceforge which has been a long standing goal.
(I know, we all prefer a good var_dump()
plus source reading to docs, but their current non-existence won’t continue)
Goals for 2.0
There were three over-arching design goals in this rewrite, plus a slew of secondary goals.
1. Support new namespaces and elements, easily
Rather then go on trying to push the universal rules for mapping unknown elements to datastructures (the Magpie 1.0 approach) I’ve focused on making it simple to register custom parsing logic, and having intelligent defaults. (aka more like what Feedparser.py does) I expect that we’ll handle most known namespaces in short order, and barring another total upheaval of the landscape ala the Pie/Atom project should sit us in good stead as feed use continues to become more sophisticated.
2. Pluggable components
You should be able to easily swap out the caching layer (database caches anyone?), the HTTP layer (multiplexed curl?), even the parser. Besides the added flexibility, the theory is this will make embedding simpler.
Who knows, maybe someone will even contribute a pluggable parser that can handle something other then well formed XML.
3. Mostly backwards compatible
For simple stuff, you’re scripts should go on working. There is still a 1 function interface (if you liked that), still bust everything down into a couple of nested arrays for easy looping and echoing. Even where different it should feel familiar.
Known Issues
- Parser doesn’t support xml:base nor xml:lang nor Atom inheritance. It will, but these features still annoy me, and as long as no one is using the code I can’t seem to motivate to support them.
- I’m also not doing all the normalization between feed types that I do in “Magpie classic”. Again, its coming.
- Not sanitizing content yet.
- Not just a new parser, but a new HTTP client as well. Basic HTTP auth support is there, digest isn’t. Haven’t added back in SSL support yet.
- No documentation per se.
Incompatibilities and Gotcha
- Just use
$item['content']
instead of$item['content']['encoded']
or$item['atom_content']
. - If caching is turned on, and Magpie can’t write to it’s cache, it will throw a fatal error, rather then quietly working in a degraded state. This might change, but its been a major support issue.
More features
fetch_rss()
now supports taking per feeds options. This was the most requested feature, ever. (e.g. cache age, output encoding, user-agent, etc)- Parses enclosures, this was the second most requested feature.
-
Handles repeated elements properly. (dc:subject, link, whatnot)
echo $item['dc']['subject']; foreach ($item['dc']['subjects'] as $subj) { ... }
- Atom 1.0 support modulo known issues.
- Tests. Most of them based on Mark’s FP tests. More added all the time. Currently not distributing with Magpie as I haven’t really figured out the license issues.
- Confusing new licensing. Stated goal is to license under a dual GPL/BSD license. That means you get to choose if you’re using the software under the GPL, or the BSD. In addition you can upgrade your license to GPL from BSD (as you can with any BSD licensed software) merely by wishing it to be so.
- Lots more, really.
Other then that, its just like Magpie