Download the PHP package vivaserver/restful_agent without Composer

On this page you can find all versions of the php package vivaserver/restful_agent. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package restful_agent

RESTful Agent

This is a simple Composer package for accessing RESTful resources using Curl. Enjoy!

Installation

The easiest way is to install it as any Composer package. Just add an entry to your composer.json 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

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

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

GET request

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

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

Pass PUT parameters as an associative array after the URL.

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

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:

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

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

This software is released under the MIT License.

Copyright

©2013 Cristian R. Arroyo


All versions of restful_agent with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
ext-curl Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package vivaserver/restful_agent contains the following files

Loading the files please wait ....