|
php
sklar.com/blog
|
Tuesday, August 29. 2006
The new edition of PHP Cookbook is on the way! I got one copy yesterday, so it should be making its way into bookstores and online-bookstore-warehouses any day now.
There is lots of new material in this edition -- completely revamped XML and OOP sections, new stuff on PDO, Ajax, testing, performance tuning, regular expressions, and lots of other goodies.
Thursday, August 24. 2006
Some neat Ning + PHP related stuff recently: Ben and Elizabeth set up a Group clone for PHPCommunity -- http://phpcommunity.ning.com.
Ben also set up an app -- http://zendfw.ning.com -- where he installed the Zend Framework and made a few tweaks so it's runnng happily on the Ning Playground. I was pleased to see that our URL mapping support can handle everything that Zend Framework needs.
Tuesday, July 25. 2006
I'm heading to OSCON today. Things I'm looking forward to (in no particular order): Portland, giving a new talk, seeing friends, learning lots of new things. If you're at (or going to) OSCON, say hi and tell me how wonderful (or stinky) you think my blog is.
Monday, July 24. 2006
XMLHttpRequest Quirks and PHP has some tips on making HTTP requests from Javascript (and is not really PHP-focused, despite the title). The brief discussion of the benefits and drawbacks of using XML, HTML, or JSON for data exchange is worthwhile, and I suppose there's nothing wrong with any of the info about the XMLHTTPRequest object, but I think if you're doing any moderately serious Javascript stuff that requires HTTP requests (see what wonderful contortions I undergo to avoid saying "Ajax"! Oops.), you've got problems if you're interacting with XMLHTTPRequest (or the IE-equivalents via "new ActiveXObject()") directly.
Instead, use a library such as Dojo or Prototype. There are a lot of subtleties to making requests work properly -- things such as cross-browser support and using different request transports based on the kind of data that needs to be sent to the server. If you start down the road of trying to do all that yourself, you'll go nuts (or at a minimum, waste your time reinventing). If you ignore all of those subtleties, your app won't work correctly.
So take advantage of the hard work someone else has already done to solve these problems. We may argue over whether real programmers use emacs or vi or Microsoft Visual InterDev 2006 for .NET Enterprise Architect Edition, but there's not much support for the "I wave a tiny magnet back and forth just-so next to the hard drive" method of editing these days. Avoid waving the tiny magnet to make HTTP requests from Javascript.
Friday, July 21. 2006

I just received a copy of PHP5. Wprowadzenie, the Polish translation of Learning PHP 5. I don't know any Polish, but if my calculations are correct (from Listing 7.13), "Kurczak generała O'Tso" is a spicy dish with chicken, dried pepper pods, maybe some peanuts, green pepper, and other goodies.
Monday, June 26. 2006
Over the weekend we launched the "Ningbar" -- what Diego, Brian, and the rest of the crew at Ning have been cranking away on for while.
The Ningbar is not just a replacement for the sidebar that used to accompany all Ning apps. It's the control center for getting the most out of Ning, whether you're using an app, cloning an app (which now takes just exactly 2 clicks), or writing code behind an app. In the Ningbar, you can get stats about the app you're using (who else uses it, what do your friends do on the app), check your messages or send messages to others, customize your apps, or clone the app you're looking at.
Of course (we wouldn't have it any other way!) the Ningbar is completely customizable and programmable. You can tweak every aspect of its appearance and behavior. And because the Ningbar sits on top of our open Javascript and REST APIs, what the Ningbar can do is only limited by what cool stuff you can think of to build. (This panel showing the current weather was a fun quick hack.)
Gina's post on the Ning blog has lots of screen shots and gives some more background on Ningbar goodies. As always, http://documentation.ning.com has the programming and API details for how to make the Ningbar do your bidding. In particular, check out the sections on our new Javascript APIs and interface customization.
Thursday, June 15. 2006
Here are slides and sample code from my talk at NYPHPCon 2006.
Thursday, May 4. 2006
I'll be giving a talk on "Metaprogramming with PHP" at NYPHPCON on June 15 16. Although PHP is not a metaprogramming paradise compared to languages such as Lisp or Ruby, there are plenty of practical techniques and neat-but-less-practical tweaks that let you bend PHP's syntax to do your bidding.
Plus, it's always nice when going to a conference means hopping on the A train instead of an airplane.
Update: The talk is on June 15, not June 16 as originally posted. The conference organizers switched a few talk slots around.
Monday, April 10. 2006
BadgerFish is an attempt to have a straightforward way to represent arbitrary XML documents as JSON objects. Think of it as SimpleXML for Javascript.
Tuesday, March 28. 2006
As Adam and Chris have mentioned, the talks for OSCON 2006 have been selected.
I'm excited that my proposal, I'm 200, You're 200: Codependency in the Age of the Mashup, was accepted.
Unlike most previous talks I've given, this one is less "here's how to do something with PHP" and more "here's an interesting problem to think about." I am also pleased to be doing my part to advance the nascent discipline of HTTP status code humor.
Wednesday, February 22. 2006
Needing to pick out some bits from a smallish (40 lines) XML document studded with namespaces, I first turned to DomXPath:
$doc = new DomDocument();
$doc->loadXML($xml);
$x = new DomXPath($doc);
$x->registerNamespace('one','first-namespace-uri');
$x->registerNamespace('two','second-namespace-uri');
$nodes = $x->query('/one:tag/two:*');
Worked great, code's concise, XPath expression is simple. But I had the nagging thought that using DOM traversal functions should be faster. So I tried:
$doc = new DomDocument();
$doc->loadXML($xml);
$firstNode =
$doc->getElementsByTagNameNS('first-namespace-uri','tag');
$nodes =
$firstNode->item(0)->getElementsByTagNameNS('second-namespace-uri','*');
The DOM traversal code is about four times faster than the XPath code. I'm going to use the XPath code, though.
That 4x speed multiple translates into about a half second to execute for the XPath code and about 0.13 seconds to execute for the DOM code when each is run 10,000 times. Since a typical use of this code will involve it running maybe 10 or 20 times during a request, I'm happy to sacrifice a few microseconds of processor time in exchange for simpler code. (Since, to me, the XPath expression is simpler and has the handy property of scooping up all the nodes that match -- the DOM code would have to be modified to loop through multiple nodes in $firstNode to get that behavior. If XPath gives you the willies and you prefer using the DOM functions, then you're in great shape.)
Whenever performance evaluation issues like this come up, I'm reminded of Adam's mini-rant that I wrote about in 2004.
Monday, February 20. 2006
I'll be chatting with Marcus on the Pro:PHP Podcast this Friday, Feb. 24 at 1pm ET. Tune into the live webcast and ask questions!
Thursday, February 16. 2006
We released a new version of Ning today. (Well, for me in NYC it was today. For the crew in Palo Alto, it was a last-night-and-this-morning experience. For the Australian connection, I'm not sure which day(s) we covered!).
Lots of neat new stuff in this release:
- Totally revamped and rewired UI for browsing around the playground, profile management, looking at your app's stats, and other system functions. As someone whose expertise tends towards the "functional but not so pretty", I am really in love with all of Paul's hard work on this design.
- That redesign extends to the Developer Documentation too -- I think it'll be easier and more pleasant to find tech specs and API docs now.
- Speaking of developer stuff, there are a bunch of new skeleton apps that make building web services apps ridiculously quick. Yoz has also put together a snazzy screencast on building a basic photo sharing app with Flickr integration.
- All the Example Apps have been given thorough overhauls, too. Jon did a lot of work on all sorts of color palette arithmetic and GD wizardry so apps now have slick setup pages that let you tweak colors and have that automatically update your entire app.
So take a peek at what's there and what's coming and let me know what you think.
Tuesday, February 14. 2006
I got my OSCON proposal (" I'm 200, You're 200: Codependency in the Age of the Mashup") in under the wire. The theme of the talk is thinking about all the dependencies your web app has -- some you're probably aware of and some you're not -- as well as strategies for minimizing those dependencies and routing around failure.
I've got a bunch of examples I'm planning on talking about (if the talk is accepted), but I'd be interested to hear other folks' experiences in solving related problems -- do you have novel methods for caching information, application or network architecture, code structure, or anything else that helps you layer reliability onto a distributed set of resources not all under your control? Let me know!
OSCON is getting bigger every year -- it's interesting to see it grow as the world of open source encompasses more and different kinds of hackers, business people, and others. Like Adam, I'm not picking PHP track talks this year for OSCON, so you can consider this post a relatively unbiased conference plug.
Friday, February 10. 2006
lxr.php.net has been around for a while, but since I've found myself using it a lot recently, I want to point it out. It's such a quick way to find the particular file a built-in (or extension) PHP function is defined. Coupled with the revision graph that cvs.php.net can display, it is handy for tracking down exactly when a function was added or a bugfix was committed.
Thanks, lxr!
|
|
|