PHPackages                             vivaserver/restful\_agent - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. vivaserver/restful\_agent

ActiveLibrary[HTTP &amp; Networking](/categories/http)

vivaserver/restful\_agent
=========================

A little library for accessing URLs using Curl in a RESTful way

0.1.1(12y ago)0171MITPHPPHP &gt;=5.3.0

Since Jul 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/vivaserver/php-restful_agent)[ Packagist](https://packagist.org/packages/vivaserver/restful_agent)[ Docs](https://github.com/vivaserver/php-restful_agent)[ RSS](/packages/vivaserver-restful-agent/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (1)

RESTful Agent
=============

[](#restful-agent)

This is a simple [Composer](http://getcomposer.org/) package for accessing RESTful resources using Curl. Enjoy!

Installation
------------

[](#installation)

The easiest way is to install it as any [Composer](http://getcomposer.org/) package. Just add an entry to your [composer.json](http://getcomposer.org/doc/01-basic-usage.md#composer-json-project-setup) file requiring the latest available version:

```
...
"require": {
  "vivaserver/restful_agent": "dev-master"
  ...
}
...

```

The package will be automatically installed when you execute the `composer install` command.

Usage
-----

[](#usage)

Create a new instance of the RESTful Agent after requiring the Composer autoloader and you should be ready to go.

```
require 'vendor/autoload.php';
$agent = new Resftful\Agent;

```

Later you should be able to use the $agent instance to perform any HTTP request.

### DELETE request

[](#delete-request)

```
$agent->delete('http://www.example.com/resources/37');

```

### GET request

[](#get-request)

```
$agent->get('http://www.example.com/resources');

```

### POST request

[](#post-request)

Pass POST parameters as an associative array after the URL.

```
$agent->post('http://www.example.com/resources',array('id'=>$id,'name'=>$name,'description'=>$description));

```

### PUT request

[](#put-request)

Pass PUT parameters as an associative array after the URL.

```
$agent->put('http://www.example.com/resources/25',array('description'=>$description));

```

Return values
-------------

[](#return-values)

The library expects that the RESTful resource will use HTTP response codes to acknowledge the status of it's returned message. Thus, the return values of the library methods is always an object with two properties:

- `code`

    The HTTP status code of the resource response.
- `body`

    The proper body of the returned response.

### Handling return values

[](#handling-return-values)

Knowing the above, just take into consideration the response code to act on the correct status of the resource. For example:

```
$response = $agent->get('http://www.example.com/resources/54');
$result = $response->body;
switch ($response->code) {
  case 200:
    return $result;
  break;

  case 404:
    return NULL;
  break;

  case 500:
    error_log($result);
  break;
}

```

Notes
-----

[](#notes)

As expected, the return value of all the methods is the output of the resource to the request.

But please not that, on library failure, an Exception will be thrown. So it's advisable to use it inside a try/catch block, like so:

```
try {
  $agent->delete('http://www.example.com/resource/37');
}
catch (Exception $e) {
  error_log($e->getMessage());
}

```

License
-------

[](#license)

This software is released under the [MIT License](http://www.opensource.org/licenses/MIT).

Copyright
---------

[](#copyright)

©2013 [Cristian R. Arroyo](mailto:cristian.arroyo@vivaserver.com)

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

4671d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/09c73d1aee5bdbf4cc82324b6c493123563778a5ebf0e84693c3d822c3dd30a3?d=identicon)[vivaserver](/maintainers/vivaserver)

---

Top Contributors

[![vivaserver](https://avatars.githubusercontent.com/u/16776?v=4)](https://github.com/vivaserver "vivaserver (4 commits)")

---

Tags

clientrestcodeigniter

### Embed Badge

![Health badge](/badges/vivaserver-restful-agent/health.svg)

```
[![Health](https://phpackages.com/badges/vivaserver-restful-agent/health.svg)](https://phpackages.com/packages/vivaserver-restful-agent)
```

###  Alternatives

[pdffiller/pdffiller-php-api-client

PHP client for pdffiller.com REST API

14140.2k](/packages/pdffiller-pdffiller-php-api-client)[chsergey/yii2-rest-client

REST client (AR-like model) for Yii Framework 2.0 (via GuzzleHttp)

1511.3k](/packages/chsergey-yii2-rest-client)[opiy-org/asterisk-ari-php

An object-oriented client for the Asterisk REST Interface (ARI). Handles ARI calls and events for you.

121.1k](/packages/opiy-org-asterisk-ari-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
