Currently browsing zend


Supporting PUT & DELETE in the Zend Framework

Wed, 27 Feb 2008 18:51 UTC

Creating a RESTful Web service is not simply about serving read-only content through HTTP GET requests. It’s about using the full range of HTTP’s constrained interface to allow clients to consume or create resources within your service. Take a look at CouchDB, for example. Its initial releases look very promising, and the server accepts GET, POST, PUT, and DELETE requests to manipulate resources in the system. I can’t wait until the project implements authentication and authorization features; then, it will look much more attractive for real-world use.

But I digress…

I’ve never been too happy with the Zend Framework’s RPC-based approach to creating RESTful Web services with Zend_Rest_Server, even though I have seen some good discussion about using routes and Zend_Rest_Server to create a resource-oriented architecture. Rather than get too in-depth about this issue, I’ll just point to this thread and save my full thoughts on Zend_Rest_Server for another day.

Suffice it to say, Zend_Rest_Server is not focused on resources but, instead, what you can do with those resources (procedures, methods, verbs) and also assumes you’re only ever going to provide an XML-based, read-only REST service. With REST, this is not the case, and, with the publication of the Atom Publishing Protocol (a protocol that follows the REST architectural style) as RFC 5023, now is the time more than ever to grasp the read-write capabilities of the RESTful Web.

But I digress (again)...

I’ve recently been wrapped up in an effort to design and implement a RESTful API using the Atom Protocol for a project at work. We are using the Zend Framework as the underlying framework for the project, so, in order to follow the Atom Protocol, I needed to support the HTTP methods PUT and DELETE. Apache can handle GET and POST easily because the request itself tells Apache the resource to use when processing the request. With PUT or DELETE, the resource identified by the request may not even exist, so Apache needs you to specify a script to process the request. To do this, I added the following lines to my virtual host configuration:

# PUT and DELETE support
Script PUT /index.php
Script DELETE /index.php

Now, all PUT and DELETE requests are handled by the Zend Framework bootstrap script and the dispatcher handles them in the same way it handles GET and POST requests.

To further support other HTTP methods and the REST architectural style, I’ve proposed the addition of the following methods on the Zend_Controller_Request_Http class:

  • isGet() – Was the request made by GET?
  • isPut() – Was the request made by PUT?
  • isDelete() – Was the request made by DELETE?
  • isHead() – Was the request made by HEAD?
  • isOptions() – Was the request made by OPTIONS?

Quoted in InfoWorld

Sat, 20 Jan 2007 17:08 UTC

Last week, I received a rather cryptic e-mail with the following subject line: “Are you available today to talk about PHP?” The body was even more cryptic: “If so, please provide a phone number. Thanks.” Normally, I would’ve tossed such a message aside, assuming that it’s either spam or someone in Nigeria wanting me to build a PHP application for them after I give them my bank account and routing numbers so they can deposit the funds necessary to complete the work, but I noticed that this message was sent by an Editor at Large from InfoWorld. So, I decided to give it a shot and send my number back to him.

Shortly thereafter I received a phone call from Paul Krill, who was writing a piece about Zend Core 2.0 (specifically with regard to Microsoft support), the Zend-Microsoft partnership, and the new CEO of Zend. Apparently, Zend was announcing their new CEO and releasing a beta of Zend Core 2.0 on the 16th (which they did). Strangely enough, I find it odd that the PHP community remained virtually quiet (literally) on these issues this week.

Nevertheless, InfoWorld ran Paul’s news story on the 16th, and I was quoted in it. I think this is the first time I’ve ever been quoted outside publications in the PHP world. Luckily for me, I was not misquoted.

Comments 2 Comments »  Permalink Permalink  Tags Tags: , , , ,


Zend Executable Debugger Eclipse Plugin

Fri, 5 Jan 2007 18:01 UTC

UPDATE (5 Jan, 21:00): Patrick Mueller has just posted some links to information about XDebug support for PDT. Now, for those not wishing to use the Zend Debugger, you may now use XDebug.

Since I last wrote about the Eclipse PHP IDE a few weeks ago, the Eclipse team has changed the name of the project to the PHP Development Tool, or PDT. So, if you’ve been looking for the PHP IDE, you can find it in the same place, but the name has changed. The name change isn’t what I wanted to write about, though. Rather, I wanted to take a moment to talk about the free Zend Executable Debugger plug-in for Eclipse.

The Zend Executable Debugger plug-in is part of the all-in-one PDT package, but if you want to install it on your own—since it’s possible to use this debugger without the PDT and with PHPEclipse, for example—then you’ll need to install it using the Eclipse Update Manager (the easier way).

To install the Zend Executable Debugger plug-in using the Update Manager, follow the instructions I provided earlier to set up a new update site using the following information:

  • PHP Development Tool (PDT)
    UPDATE URL: http://downloads.zend.com/pdt

    Please note that the Zend Executable Debugger is not available from the Eclipse site’s PHP update URL listed in my earlier post. Instead, you must use the Zend update URL (listed here) to install the debugger. When installing, if you already have the PDT installed, simply choose to install only the Zend Debugger.

    Install the Zend Debugger

    Once installed, you can debug a PHP script by selecting the script and choosing Run > Debug As > PHP Script, and that’s all there is to it. The debugging output appears in the console tab, shown here:

    PDT-DebugConsole

    Comments 21 Comments »  Permalink Permalink  Tags Tags: , , , , , , ,


ZendCon & IPC Wrap-ups

Tue, 19 Dec 2006 15:09 UTC

This post is long overdue, but I was finally able to sit down and type out my thoughts about the Zend/PHP Conference and Expo and the International PHP Conference. I had the privilege of being invited to speak at both of these conferences, and I accepted both invitations, which, in retrospect, may not have been a great idea since they were back-to-back in different parts of the world; I felt like I knew the NSA on a first-name basis. Looking back, though, I enjoyed each trip because I was able to meet new people, develop new friendships, and spend time with old friends.

Zend/PHP Conference Wrap-up

Zend/PHP Conference and Expo 2006

The Zend Conference started out great, ushering in a new era of the community-made t-shirt, and the week was awesome up until the moment immediately following my presentation. The week started with a visit to a couple of wineries for tastings, courtesy of Andrei (our chauffeur). We also had some great dinners, and I was able to catch up with a few friends and meet some people I have only spoken with via e-mail. The day of tutorials was excellent; I sat in on Rob Richards’s “Advanced XML and Web Services” and Marcus’s and Sara’s “Extending PHP” tutorials. Both were very informative, though I would’ve liked to have seen more practical examples of Web Services, and I wish my attempt to connect to Sara’s ad hoc network hadn’t hosed my wifi connection (it took a full day to connect to any other wifi network and pick up an IP address). It is important to mention, though, that the ZendCon wifi was outstanding (compared to other conferences).

Then, the disaster came that ruined my enjoyment of the entire week.

On Tuesday afternoon, immediately following Chris Anderson’s keynote presentation, I gave my “XML & Web Services with PHP” presentation. While setting things up for the presentation, I removed my laptop and power cables from my bag, and then placed my bag on the ground—I thought it was at my feet. After my presentation, however, my bag was missing, along with my camera, iPod, spare laptop battery, folders of work and writing notes, and more. Luckily, I had my laptop, but I was nevertheless livid. After a thorough search of the area, checking with hotel and conference staff, and posting a “lost bag” notice, I still hadn’t found it. And it never turned up during the entire week. It was all I could think about. I couldn’t focus on any of the presentations, and I wrote it off as having been stolen, which made me even more angry that someone would steal my bag right out from under me and that this bastard was a member of the PHP community.

On the Saturday following the conference, Chris Anderson—yes the keynote presenter and editor-in-chief of Wired Magazine—contacted me saying that he was in possession of my bag. From what I can gather, it seems that when they were closing the walls of the main conference room to divide it into the three session rooms, they closed my bag on the other side of the wall from the room in which I gave my presentation. Since the bag was near the stage of the middle room, someone assumed it belonged to Chris Anderson who had just given his keynote presentation from that stage. What happened next is left to interpretation. Chris told me that the “gift bag they handed [him] at the Zend conf registration” appeared to be the bag I had lost. There are two things that could have happened: 1) someone turned in the bag, claiming it was Chris Anderson’s, and he assumed it was his “gift bag” when they returned it to him, or 2) the conference organizers had Nike bags similar to mine to give to the keynote presenters, and when they found my bag, they assumed it was one of their gift bags, so they took it back to the registration tables and gave it to Chris. In either case, he somehow ended up with my bag as his keynote gift.

At any rate, Chris quickly returned my bag, and my faith in humanity and the PHP community was restored. Still, the conference was a bit ruined for me, but that doesn’t say anything about the topics, speakers, or Zend. The last night of the conference was great, though, complete with an IBM pirate-themed party and Microsoft-sponsored drinks and karaoke. There are pictures floating around on Flickr.

International PHP Conference Wrap-up

The last time I spoke at the International PHP Conference was during the Spring Edition 2005 in Amsterdam. The location in Amsterdam was ideal. It was right next to a train station, and a tram stop was only a couple of blocks away, giving conference goers easy access to the entire city. The conference location in Frankfurt, while undoubtedly cheaper than Amsterdam (you can’t beat €87 a night!), was farther out from the city with no nearby train stations (the closest was several kilometers away). While I was able to explore Amsterdam everyday during my stay, I managed to leave the Frankfurt hotel only one night.

International PHP Conference 2006

My complaints, however, deal primarily with the location. The conference, on the other hand, was excellent, as usual. The organizers, S&S, always put on a polished and well-presented conference, complete with excellent conference materials, right down to the programs, badges, and hoodies given to speakers. The European atmosphere feels familiar with noticeable differences—chances are, if an attendee has a Mac, they’re from the US, while the Europeans tend to have IBM hardware. Also, what is the German obsession with sparkling water and small glasses? Perhaps it’s my gluttonous Americanism, but I love to drink lots of water (without bubbles). Nevertheless, it’s not hard to get used to, and, since I’ve returned, I’ve found myself craving a glass of sparkling mineral water on occasion.

While at the IPC and in-between trying to fulfill work commitments, I managed to make it to Aaron Wormus’s workshop on “Mastering enterprise-level PHP tools PEAR, PhpDocumentor and testing,” Marcus’s “The Need for Speed, ERM Testing,” and Sara’s “Navigating Streams.” Two great highlights of the conference were the PHP-Lounge and Code Camp (led by Marcus and Sara). I didn’t make it to the Code Camp, but I’ve heard good things about it, and the PHP-Lounge was a great place to speak with other developers, share ideas, and have fun—free beer always helps, too. In addition, I gave talks on “Designing & Implementing RESTful Web Services” and “Filtering Tainted Data: PECL Input Filter vs. Zend_InputFilter.” Following the conference, there was some discussion around the PHP blogosphere about comments I made during my filtering presentation; a (near) future blog post will continue that discussion and provide some answers and clarification.

On the last night of the conference, a small group of us did manage to escape the confines of the hotel. We took a taxi to a local restaurant, where I had a traditional German dish and a Czech beer. After dinner, we walked several blocks until we found train tracks, and then we followed them for a kilometer or so until we came to the station. We then made it into the heart of Frankfurt, where we were able to do a little site-seeing before sampling a few more beers and returning to the hotel. I’ve posted pictures to my Flickr account.

Comments 4 Comments »  Permalink Permalink  Tags Tags: , , , , , , , , ,


Installing the Eclipse PHP IDE

Mon, 18 Dec 2006 17:51 UTC

I recently wanted to try out the Eclipse PHP IDE, the official Eclipse project that is endorsed/backed by Zend (I’m not entirely sure about the nature of their relationship, to be honest). I already had a working Eclipse installation that I had used to try out PHPeclipse for Eclipse (not to be confused with the PHP IDE), so I didn’t want to bother downloading a brand new full package of Eclipse that includes the PHP IDE and all its requirements. So, I set about on a tedious journey to figure out how to install PHP IDE using the Eclipse Update Manager. These are my notes.

NOTE: If you don’t already have a working copy of Eclipse and you want to try out the PHP IDE, then these notes are not for you. Simply download the full package and install it. Everything should work fine out of the box. These notes are for those who have a working installation of Eclipse, want to install PHP IDE via the Update Manager, and are having trouble finding all the download sites for the PHP IDE prerequisites.

Disable PHPeclipse (if needed)

First off, if you have PHPeclipse installed, you’ll need to disable it. Navigate to Help > Software Updates > Manage Configuration. From the tree on the left, find PHPEclipse, highlight it, and choose the “Disable” link from the pane on the right.

Disabling PHPeclipse

Install the PHP IDE Prerequisites

Setting Up a New Update Site

The PHP IDE installation page lists a handful of runtime prerequisites for the PHP IDE plugin. However, it doesn’t list any URLs directing you to where the projects are located or what Update Manager URLs to use. Thus, I’m providing those links here.

For each of these prerequisites, you must follow these steps to install the package via the Eclipse Update Manager:

  1. Open the Update Manager at Help > Software Updates > Find and Install…
  2. Select “Search for new features to install” and click the Next button
  3. Click the New Remote Site… button on the right
  4. Enter a name and the update URL for the update site, click OK
  5. Make sure the checkbox next to the new site is checked and click Finish
  1. Follow the prompts to install the new package

    Now that you know how to install the packages, here are the prerequisites and their update URLs:

  • Web Tools Platform (WTP)
    UPDATE URL: http://download.eclipse.org/webtools/updates/

    Install the PHP IDE Plugin

    Now that you have installed all the prerequisites, you are ready to install the PHP IDE plugin, and you shouldn’t encounter any problems now since all the prerequisites are available. To install the PHP IDE plugin, follow the same directions above to set up the PHP IDE update site in the Update Manager using the following update URL:

  • PHP IDE
    UPDATE URL: http://download.eclipse.org/tools/php/updates/

Comments 31 Comments »  Permalink Permalink  Tags Tags: , , , , , ,


XML & Web Services Slides

Tue, 31 Oct 2006 23:12 UTC

I’ve just finished giving my presentation on XML & Web Services with PHP (An Overview). Overall, I think the presentation went quite well, though I had entirely too much material to cover in a very short period of time, so it was impossible to go into much depth on any one type of Web Service. This was unfortunate, but I think the “overview” nature of the presentation allowed for this top-level approach.

As promised, here are the slides from the presentation (PDF, 2 MB), and what follows is the list of links for further reading:

Further Reading

XML-RPC

Comments 1 Comment »  Permalink Permalink  Tags Tags: , , , , , ,


ZendCon Day 1 Roundup and Keynote Thoughts

Tue, 31 Oct 2006 18:42 UTC

The first day of the Zend/PHP Conference and Expo (the day of tutorials) was great. I sat in on Robert Richards’s Advanced XML and Web Services and Marcus’s and Sara’s Extending PHP tutorials. I multi-tasked as best I could, catching up on some work while finishing my slides and listening to the presentations. Robert went into a great deal of information on DOM, which was all very excellent material—you can definitely tell where his passion lies and that he knows his stuff—but discussion on Web Services was not very prominent. My presentation today, though, while entitled “XML & Web Services with PHP” will be nearly the opposite and discuss Web Services in general, while glossing over XML. So, I think the two properly balance each other. Marcus and Sara covered PHP extensions brilliantly, but, while WiFi here has been excellent, trying to connect to Sara’s ad hoc network for the presentation hosed my wireless connection, and I couldn’t connect for the remainder of the day from the presentation rooms.

For another roundup of the conference tutorial day, I’d suggest reading Aaron Wormus’s take on the day. Unfortunately, Aaron’s server is currently down, so he’s unable to blog on his site (or receive e-mail for that matter), so his roundup post is on PHPDeveloper.org. Be sure to check it out.

This morning, the opening keynote of the conference was led by Mark de Visser, Andi Gutmans, and Zeev Suraski. Mark is Zend’s Chief Marketing Officer, and I’ve had the pleasure of talking with him at OSCON and again last night at the speakers/ZCE dinner. He has a great feel for the PHP and open source community, and he’s sensitive to the appearance and presence of a corporation within this community. I think he brings a wealth of experience to Zend, given his background at RedHat, and he’s doing a great job building Zend’s relationship with the community and presenting them in a manner that is acceptable to the community as a whole.

The keynote covered a range of topics, including the current state of the PHP Collaboration Project, a demo of the new Google Data client library in the Zend Framework, the Eclipse PHP project, Zend Platform and Zend Studio, and the future direction of PHP. Mentioned, also, was the imminent release of PHP 5.2, which might be available this coming Thursday. Overall, the keynote was good, informative, and well-presented, though I felt the introductory part of the keynote, in which some applications, such as Joomla and ZenCart, were showcased, did not show off the strengths of the current state of PHP. These applications are still using PHP 4, for the most part, and I think it would have been good to showcase applications that take advantage of the powerful features of PHP 5 to create a “Web 2.0” application.

In all, it’s been a great conference thus far, and it’s just getting started. I’m heading now to Eli White’s High Volume PHP & MySQL Scaling Techniques, and then, after lunch, I’ll be giving my XML & Web Services with PHP presentation.

Comments 2 Comments »  Permalink Permalink  Tags Tags: , , ,


PHP Throwdown (and Zend Con)

Mon, 30 Oct 2006 17:46 UTC

I’m at the Zend/PHP Conference and Expo right now sitting in Robert Richards’s Advanced XML and Web Services tutorial. I’ll be attending Marcus’s and Sara’s Extending PHP tutorial later today. Had a great day yesterday, in which Andrei drove us to wine tastings at two different wineries: Ridge and Picchetti.

I wanted to take a moment to mention a 24-hour coding marathon announced by Elizabeth Naramore: PHP Throwdown. The competition sounds exciting, and I’m hoping to get a group together from Atlanta PHP to participate. It’s still in the planning stages, so you need to keep your eyes on it for announcements and more information. For now, here are the details:

What: 24-hour coding competition to see who can code the best PHP app
When: January 27, 2007
Who: You! You may enter individually or as a team, so if you think you’ve got what it takes then read more.

Comments 1 Comment »  Permalink Permalink  Tags Tags: , , , , , ,


Off to the Zend/PHP Conference and Expo

Sun, 29 Oct 2006 4:22 UTC

I’m flying out to San Jose tomorrow for the Zend/PHP Conference and Expo. Does anyone know the way? ;-)

I’ll be speaking at this conference on Tuesday during the 2:30pm time slot. My presentation is an overview of Web Services entitled “XML & Web Services With PHP (An Overview).” The abstract follows:

What is XML? What are Web Services? This talk will answer both of these questions, exploring ways to use the powerful features of PHP 5 to consume and create XML-based Web Services. Topics will include SOAP, XML-RPC, and REST, giving real-world examples and explaining the differences between and benefits of each.

There are many things I’m looking forward to during this conference, including:

#phpc T-Shirts

Thu, 12 Oct 2006 14:09 UTC

Since there will be a substantial number (something like 9 or 10) of #phpc frequenters in attendance at the Zend/PHP Conference and Expo, we decided it would be cool to print up some t-shirts for fun and wear them at the conference. So, quickly, Aaron Wormus came up with a t-shirt design, and we’re ready to start printing them. Tuesday, October 31 will be the official #phpc wear-your-t-shirt day for conference goers.

If you want a t-shirt, please send an e-mail to tshirts [at] benramsey.com and include your size. This is how I’ll get a head count for the initial printing. I need a count soon, so don’t delay! The cost of the shirt will be about $13. I’ll bring them to the conference to hand out. If you can’t make it to the conference, and you still want a shirt, I’ll arrange for shipping after the conference (but go ahead and let me know you want one now).

Comments 3 Comments »  Permalink Permalink  Tags Tags: , , , , ,