Download the PHP package collectiveaccess/service-wrapper without Composer

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

A simple PHP wrapper for the CollectiveAccess JSON-based REST web service API

Please visit https://www.collectiveaccess.org for more information and refer to https://manual.collectiveaccess.org for detailed information on the service API and other features of the core software.

Basic usage

You can install this library via composer and then take advantage of composers flexible autoloading feature. From there you can just use all the service classes in the CollectiveAccessService namespace.

For example:

This should get you a generic summary for the object record with object_id 1.

Here are some more simple examples for the other service endpoints to get you started:

Authentication

To use authentication, you basically have 3 options. The first is to use the PHP constants __CA_SERVICE_API_USER__ and __CA_SERVICE_API_KEY__ as shown in the next example, This comes in handy if you want to run multiple service requests in the same script.

Note that all 3 authentication options try to retrieve an authToken from the remote service, save it in a temporary directory and re-use it as long as it's valid. When it expires, it re-authenticates using the username and key provided using one of the 3 options below. user/key are not used in the mean time.

Now back to option one - the constants:

You can also use a simple setter:

The 3rd option (and probably most suitable for production) is to pass the credentials as environment variables CA_SERVICE_API_USER and CA_SERVICE_API_KEY. Imagine this simple script as authtest.php

Then running something like this in a terminal should work:

To do this in a web server setting, you could look into apache's mod_env.

Retrying failed connections

As of version 1.1.3, the wrapper can automatically retry failed connections. In this context "failure" occurs when a connection cannot be established or is terminated while a request is in progress. A request that returns an HTTP error such as 401 (authentication required) will not be retried.

By default, no retries are attempted. Use the setRetries() method to set the maximum number of tries before giving up. Use the setRetryDelay() method to set the time delay between retries. Times are specified in milliseconds.

For example, to connect to the item service with up to 5 retries and a delay between retries of two seconds:


All versions of service-wrapper with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 collectiveaccess/service-wrapper contains the following files

Loading the files please wait ....