Making RESTful Requests in PHP

How to GET, POST, PUT, & DELETE in PHP

APIs have become a very commonplace part of many popular web sites and services… especially REST APIs. I’ve already discussed how you can roll your own REST API for your PHP apps, but I’ve also received countless requests to go over how to actually make RESTful requests. That’s exactly what we’ll take a look at in this article. Before we dive in, however, I want to make sure you’ve got a basic understanding of how REST APIs work, so if you’re a bit shaky or unfamiliar with the concept, head on over to my previous article on REST and read up (you don’t need to go over the implementation stuff if you don’t want, just read the first part of the article). Seriously, do it… this article is written with the assumption you’re familiar with the concepts of REST.

Anyway, without any further delay, let’s take a look at what we’re going to cover…

Read the rest of this entry »

Create a REST API with PHP

Your apps never had it so good
Create

One of the latest (sort of) crazes sweeping the net is APIs, more specifically those that leverage REST. It’s really no surprise either, as consuming REST APIs is so incredibly easy… in any language. It’s also incredibly easy to create them as you essentially use nothing more than an HTTP spec that has existed for ages. One of the few things that I give Rails credit for is its well thought-out REST support, both for providing and consuming these APIs (as its been explained by all the Rails fanboys I work with).

Seriously, if you’ve never used REST, but you’ve ever had to work with (or worse, create) a SOAP API, or simply opened a WSDL and had your head explode, boy do I have good news for you!

Read the rest of this entry »

Hello Gen-X-Design

Hi all.

This is just a short post to introduce myself. The talented Mr Selby has kindly invited me on board to blog about my experiences with mad scientist level JavaScript.

My names Davey and I work with Ian at Aptana, my role there is JavaScript Architect and as I result I spend a lot of time rooting around in the arcane depths of spidermonkey. I’m predominately interested in the topic of server side JS as it appears in our Jaxer product but occasionally venture out into the hostile environment that exists on the client.

I have an article primed and ready to go, but just need to put some finishing touches to it before publishing, In it I explore how to reproduce some of the interesting PHP capabilities that Ian is the master of. So it you have ever wanted to have the equivalent of __FILE__ or the __autoload function in javascript, keep watching all will be revealed soon.

As a first tip to any would-be JavaScript ninja, I heartily recommend The Douglas Crockford book ‘JavaScript, the good parts’, it’s just choc full o’ goodness.

cheers

Server-Side JavaScript – All the Cool Kids Are Doing It!

That’s right kids, I’m speaking at the 6th International AJAX World RIA Conference & Expo! I’ll be giving a session on server-side javascript, and how it will make your life better, your apps cooler, and your friends jealous!

Read the full entry for details on the session, but here’s a little introductory overview (for the sake of not re-writing everything, I have just copied and pasted the announcement)…

Server-side JavaScript (SSJS) is growing in popularity fast since developers realize it can drastically simplify Web app creation by letting you use using the same technology stack on both the client and the server. While server-side JavaScript is not new – it was a part of Netscape’s vision 10 years ago – times have significantly changed with 10x faster hardware and networks, making that original vision for the Web now a reality.

In this session delegates will learn how to:

  • Overcome common hurdles and pitfalls of client-side only JavaScript development.
  • Speed up development time by cutting out extra server-side code and processing scripts that are no longer necessary.
  • Clean up your code base by reducing (or even eliminating) the number of languages needed to leverage to accomplish common tasks (i.e. Why bother with server-side PHP scripts to fetch database results when you can do it all in JavaScript on the server? Why mess with Curl to fetch content that your JavaScript code can grab in one line?)

Read the rest of this entry »

Ajax Activity Indicators – Make Them Global and Unobtrusive

EDIT (7/10/2006): After much feedback, both on this site and ajaxian, I feel that I failed to properly explain where this implementation would be useful. If you have a page with a single action, say a live search for example, separating the indicator from the action is poor form from a usability standpoint. However, a dashboard page with a couple widgets and some live updating data, or some other instance where a lot of ajax may be happening on a page at once would be a perfect use for what I write about. Thanks to everyone for their comments, feedback, and advice.

One of the coolest things about developing ajax-enabled applications and sites is the level of interactivity that you can bring to your users. And perhaps one of the most crucial aspects of this process is adding activity indicators to your site. While a lot of ajax requests can be very fast, it’s still important to let your users know that something is happening. All too often I see people forgetting to add these indicators, purposefully omitting them because there wasn’t a good place to include them in the design, or implementing them poorly. One of the biggest omissions that I see is with live searches and auto-completion widgets, but not without good reason. Activity indicators can break up a good layout, as they can require a fair amount of page real estate. They’re also a major pain to incorporate into your apps, as you often end up writing a lot of redundant code to display and hide different indicators on different pages or parts of a page.

So, what can we do about these problems? Well, if you’re using prototype as a part of your framework, you can register global indicator functions. These get executed when there are active requests, and when the requests complete. However, there’s another dilemma with this method too: Where do you place a indicator that can potentially appear often and keep it from being obtrusive, or, even worse, not being seen as it’s placed outside of the content that’s currently in view? I had to tackle that issue this week while starting development on a new project at work. I wanted to create an indicator that would be in the same place on every page, and that I never had to write extra code to use. View a demo of the solution here.

The solution, in hindsight, seems very obvious and I can’t believe that I hadn’t come up with it earlier: Place a div that spans the entire width of the window at the bottom of the window and make it stick there when the user scrolled. Then use scriptaculous, or moo.fx (whichever you prefer) to show/hide the indicator when ajax requests were made/completed respectively. So how did I do it? Read on…

Read the rest of this entry »