sfActiveResourcePlugin - 1.0.1

The sfActiveResource plugin is an implementation of the ruby ActiveResource approach to consuming REST based services

You are currently browsing
the website for symfony 1

Visit the Symfony2 website


« Back to the Plugins Home

Signin


Forgot your password?
Create an account

Tools

Stats

advanced search
Information Readme Releases Changelog Contribute
sfActiveResourcePlugin 1.0.1stable for sf 1.4sf 1.3 MIT
Plugin image
2
users
Sign-in
to change
your status

The sfActiveResource plugin is an implementation of the ruby ActiveResource approach to consuming REST based services based initially off the PHP lib by John Luxford http://github.com/lux and extended to support a more flexible approach for use with Symfony 1.3+.

It supports all the things you'd expect from a REST based consumer, flexible parameters, named methods and support for callbacks from REST servers.

Overview

The sfActiveResource plugin is an implementation of the ruby ActiveResource approach to consuming REST based services based initially off the PHP lib by John Luxford http://github.com/lux and extended to support a more flexible approach for use with Symfony 1.3+.

It supports all the things you'd expect from a REST based consumer, flexible parameters, named methods and support for callbacks from REST servers.

Usage

The current implementation can make use of simple named wrappers for setting the initial properties:

class notification extends sfActiveResource {
  var $site = 'https://xxxxAPI-IDxxx@messagepub.com/';
  var $request_format = 'xml';

  public function send() {
    $this->save();
  }

}

Using it is a snap - here's an example for using the MessagePub Service:

$notify = new notification(
    array(
      'body' => 'Message body..',
      'subject' => 'Subject line...',
      'recipients' =>
        array (
          'recipient' =>
              array (
                'position' => 1,
                'channel' => 'email',
                'address' => 'person@example.com'
              )
        )
    )
);

$notify->send();

If the remote REST service supports callbacks - then you can provide a module/action that the sfActiveResource API should invoke when it receives the callback - along with an optional controller should you wish to use a different symfony app.

$postbackUrl = Notification::callbackURL(module, action, $this->getController());
$notify = new notification(
   array(
     'postback_url' => $postbackUrl,
     ...
   )
);

$notify->send();

Included Service Examples

MessagePub Messaging

Zerigo DNS Privisioning

Included in the doc folder are a few extra examples to illustrate how to use the plugin.

Coming Features

Using the Symfony Components DI container to better encapsulate and describe the services. Currently with the defining your own simple class is cumbersome - a lot of overhead for a little convenience. It would be far better to use a simple YML or XML approach to describing the service instance.

The DI container however needs a little tweaking to support this type of approach.

Updates

Updated with the DNS examples and some tasks to help setup and manage hosts via REST. There's now an optional dependancy on the sfBrowserPlugin which allows us to use a web service for obtaining our public IP address.

Developers

Name Status Email
gravatar dasher lead ku.oc.gniknihtderipsni <<ta>> rehsad

License

Show source

Copyright (c) 2004-2008 Francois Zaninotto

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.