Download the PHP package komodohq/siesta without Composer

On this page you can find all versions of the php package komodohq/siesta. 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 siesta

Siesta

Easily add API Consumption to your PHP Classes.

Siesta will add methods to consume your JSON REST API and convert the results to instances of your PHP models.

Installation

composer.json:

Usage

Methods

Siesta::find

Performs a GET request to /<endpoint> that returns a collection of items matching the supplied query parameters.

NB. This method is also used by the findOne method so be aware if you override this method it will also affect that method.

Siesta::findOne

Performs a GET request to /{{endpoint}} and returns the first result to match the supplied query parameters. Sets an additional limit parameter to 1 so if the API being consumed supports that it will limit the amount of responses returned and save work on your end.

Siesta::findById

Performs a GET request to /{{endpoint}}/{{this->id}} and returns a single result with the matching id.

Siesta::create

Performs a POST request to /{{endpoint}} with the supplied data and returns the newly created resource.

$siestaItem->update

Performs a PUT request to /{{endpoint}}/{{this->id}} with the supplied data and returns the updated resource. It will also update the local resource with any fields that have been updated on the server.

$siestaItem->save

Performs a PUT request to /{{endpoint}}/{{this->id}} with the current resource and returns the updated resource. It will also update the local resource with any fields that have been updated on the server.

If the resource has not already been saved to the server (doesn't have an id set) this method will perform a POST request instead. The local object will then be updated with the newly created id.

NB. This method is also used by the update method so be aware if you override this method it will also affect that method.

$siestaItem->delete()

Performs a DELETE request to /{{endpoint}}/{{this->id}} and returns an associative array representing the HTTP response body returned from the server.

Customisation

Siesta::$siestaConfig

To configure your class to use Siesta you need to add a private static $siestaConfig variable to your class. This is an associative array which can contain the following keys:

Siesta::populate

To change how a new model is created from the returned API data you will need to override the populate method. The default passes the returned data as an associative array to the class' constructor method.

But say you wanted to pass the properties as individual arguments to the constructor, you could override it in your class definition so it looked like this:

Siesta->toArray

Siesta adds a public toArray method to your class. This is used to serialize the class for sending in a save request. The default merely calls get_object_vars on itself, like so:

but you can override that to provide your own serialisation.

Siesta->setValue

Siesta adds a public setValue method which is used by the update and save methods to update properties based on the response from the server. The default just sets the property to the value.

You can override this to perform any extra manipulation on the properties before setting them.

Exceptions

SiestaGeneralException

Base class for any general exceptions. Stores the response body which can be retrieved like so:

SiestaClientException

Exception class for HTTP error codes in the 400 range. Extends SiestaGeneralException.

SiestaServerException

Exception class for HTTP error codes in the 500 range. Extends SiestaGeneralException.

Laravel

If using Laravel you can omit the URL config variable for Siesta and it will look for Config::get('api.url') instead.

TODO

Tests

Run composer install to get the testing library.

Start the test API server

Run the tests

Contributing


All versions of siesta with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
guzzlehttp/guzzle Version 4.*
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 komodohq/siesta contains the following files

Loading the files please wait ....