All Posts Tagged With: "php"

MySQL Users Conference 2005

I just received word that I’ll be giving an encore performance of “PHP 5 + MySQL 5 = A Perfect 10” (PPT) at the MySQL Users Conference 2005. Date and time still TBA, but the conference runs from April 18 – 21, 2005 and is at the Santa Clara Westin. Happily, that’s only 15 minutes from work, so it’s an easy drive.

Maybe this time I’ll actually talk about MySQL 5.0. When I first gave the talk, back in July at OSCON, it was really PHP 5 + MySQL 4.1 = An Above Average 9.1“.

PHP in Canada: PHP West and PHP Quebec

For some reason, we can’t seem to get any PHP-only conferences here in the US. Fortunately, our hockey-playing, maple syrup-drinking, funny-speaking brothers to the north, have stepped up to fill the gap.

Following on the success of 2004, there are two excellent looking PHP conferences coming up in 2005: PHP West and PHP Quebec.

PHP West is a one day mini-conference in beautiful Vancouver, BC. Much to my disappointment, I missed out on last year’s, but there’s another one coming up on January 14th. Best of all, it’s focused on Web services.

Right now, I’m thinking these guys really need to hear something on building e-commerce applications using eBay. Stephen’s doing such a good job with Services_Ebay, that I don’t think it’s fair to let the Europeans keep it to themselves. We need to have a North American talk to share in the goodness.

Unfortunately, PHP West is right at the end of MacWorld, so I need to check my schedule to see if I can make it. Stay tuned for more details.

The other conference, PHP Quebec, is in Montreal on March 31st and April 1st. I attended last year — speaking on Web services — and had a blast. Everyone was really nice and there were many other great speakers, including Rasmus.

I encourage everyone who can to drop by and join in on the fun. You might not be able to make both, but whether you’re an east coast or west coast guy, there’s something for you.

PHP Streams Sucks! PHP Streams Rocks!

fopen()

I often think the most overlooked and underrated part of PHP are streams. First added in PHP 4.3 by Wez, streams enable the magic that lets you call file_get_contents() (and friends) on more than just local files, but also remote files using ftp, http, https, etc.

In PHP 5, you can do lots of really cool things with streams, including filtering them using a concept similar to Unix pipes. You can also define your own stream wrappers in PHP, so you can “speak” LDAP or to shared memory using fopen() and other file system commands.

This totally rocks. You should really check it out.

At first, I thought nobody used streams because it wasn’t documented. Lots of PHP books have been queued up waiting for the release of PHP 5, so a PHP 4.3 feature didn’t have the chance to make it into print. However, the streams documentation on PHP.net is actually quite comprehensive.

When I wrote the “Streams, Wrappers, and Filters” chapter in “Upgrading to PHP 5,” I was able to find quite a bit of information in the manual if I was willing to look around long enough. Normally, I needed to do quite a bit of wrangling about amid the mailing lists, CVS commit logs, test cases, and the source code itself. (Or, if all else failed, I broke down and e-mailed the author directly.)

However, the more I play with streams — or to be more specific the HTTP wrapper — the more I run into trouble. Everything works fine for plain-vanilla requests, but when I try to do a more complex HTTPS POST request, then I run into mysterious issues and frustrating limitations.

For instance, you can only make HTTP 1.0 requests. You can’t use HTTP 1.1. And I’m running into this weird problem that seems to occur because PHP sends the request in chunks, and one of those divides is between the opening line and the Host HTTP header. (Even worse, since it’s an HTTPS request, I can’t easily monitor the wire.)

I don’t know whether it’s a “bug” in PHP, the web server, or a vagueness in the HTTP specification, but, honestly, I don’t really care. I just want it to work. Not surprisingly, implementing a protocol is somewhat subtle and tricky, and maybe it doesn’t make sense to embed your own handwritten HTTP and FTP client libraries inside of a language. Maybe it’s better to save the headache and just use cURL. (And, indeed, the request does work great when I do.)

This attitude has led to a clear tension over the future direction of streams. There was a bit of a fuss on php-internals a few months back, last time someone contributed a major patch to the HTTP wrapper. The prevailing sentiment was exactly what I just described: don’t continue to reimplement cURL inside of PHP, but figure out how to better embed cURL as stream wrappers.

Sadly, this hasn’t happened. Instead, there’s been no progress in either direction.

So now I’m stuck. I’d like to remove cURL entirely from the equation, if for no other reason than to remove a dependency on yet-another extension. Yet, cURL seems to be the way to go for anything serious — if for no other reason than it works and the HTTP wrapper doesn’t.

But if cURL is good, why are we bothering with streams and wrappers in the first place? Am I crazy for not wanting to use both cURL and streams? What’s a good PHP 5 programmer to do?

fclose()

Services_Ebay

My man Stephan Schmidt just released the first version of a kick ass eBay API PEAR package for PHP. Our XML Web services API is pretty easy to use technically, but we don’t go a great job integrating all 70+ API calls into a coherant structure.

When Stephan designed Services_Ebay, he took a step back and looked at how all the different calls should play together. This allowed him to implement a very slick object-oriented package that makes it simple to use eBay from PHP.

There are still a few tricky bits to figure out, but I’m quite impressed with what he’s done so far. Check it out. It uses lots of new PHP 5 features, such as __call() and iterators, to simplify the code, so it’s a great way for you to look at why you should be Upgrading to PHP 5. (Okay, I couldn’t resist the plug.)

World Tour: Utah PHP

Do you love PHP? Do you love eBay? Do you live in Utah? If you answered “yes” to all three questions, then you don’t want to miss the next stop on my world tour.

Next Tuesday, October 19, I will be visiting the Utah PHP Users Group to give a talk on Developing Applications on the eBay Platform with PHP. Start time is 7 PM and we’ll go until 8:30.

O’Reilly has arranged to send a carton-load of books, and I will be bringing a bag full of eBay schwag, so they’ll be giveaways gallore!

Writing for PHP 4 and PHP 5

A few weeks ago, John Lim kindly reviewed Upgrading to PHP 5. Overall, I was very happy with his comments, particularly when he said:

Even though I have read widely about PHP5, I still found this book a useful reference, because it delves deeper into the new features than most articles I have seen.

There’s a lot of free PHP 5 material, and I was a little worried that people wouldn’t find anything new in the book. It’s a good sign if John, who reads widely on PHP 5, learns something.

He also had one critique: that I didn’t spend enough time covering how to port code from PHP 4 to PHP 5. At first, this surprised me, as I specifically provide both PHP 4 and PHP 5 code examples.

Then I realized our PHP migration experiences are totally different. When I moved to a new version (and I’ve made many, as I started PHP programming with PHP/FI, aka PHP 2), I ported internal applications. I didn’t worry about other people running my code.

In contrast, John writes ADODB. This is an external application. He’s not writing for his personal or corporate use. He’s writing for everyone and anyone.

I could control my environment. While I know people would be running under shared hosts, I figured they could at least control whether they’re using PHP 4 or PHP 5.

John, however, doesn’t have that luxury. He needs to write code that can run under both PHP 4 and PHP 5. That’s why he wants me to discuss “features such as PHP_VERSION, phpversion(), extension_loaded(), function_exists(). I don’t cover that at all.

If you need these this, I guess you’ll have to wait for the second edition. :) However, I think if I was in this situation, I’d create a separate PHP 5 branch. There are so many PHP 5 specific features that just don’t play well with PHP 4, and I wouldn’t want to limit myself.

I’m interesting in hearing what other people are doing. I’ve only been following the PEAR folks a little bit. How has this been playing out?

Vegas baby! Speaking at ApacheCon 2004

I just heard that I’m going to be speaking at ApacheCon 2004 in Las Vegas on Tuesday, November 16th. I’m going to be giving my “PHP 5 Sucks! PHP 5 Rocks!” talk. If you missed it at OSCON, here’s your second chance.

I will also be hosting an eBay BOF. Place and time TBA. If you’re an eBay developer, want to write applications that talk to our Web services APIs, or just interested in hearing stories about why eBay is cool, be sure to come on by. At our last BOF, we talked about clear plastic raincoats, so this one is bound to be just as interesting, if not more so.

There are quite a few excellent PHP talks this year at ApacheCon: Chris Shiflett’s speaking on PHP Security and co-presenting with Geoff Young on testing PHP applications using Perl. (Honest! It’s a serious talk. In fact, it may be the first PHP talk I expect to learn something from in years.)

Also, Christian Stocker is giving two talks on XML in PHP 5: “XML on Crack” and “XML on Speed.” (Really. I can’t make this stuff up.) Christian’s been a big force behind XML in PHP for years. If you’re at all interested in PHP and XML, you’ll want to listen to his presentations, as you’re bound to learn three or seven new tidbits you can use at home.

And, of course, Andi Gutmans is giving the obligitory “Introduction to PHP 5” presentation. (He seems to come to quite a few more conferences now that he lives in Silicon Valley instead of Israel, doesn’t he?)

OSCON 2004 Slides Now Available

Under the heading of better late than never, I have placed my OSCON 2004 session PowerPoint slides online:

I still need to clean up my tutorial, so that’s not yet available.