PHPackages                             collectiveaccess/service-wrapper - 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. [API Development](/categories/api)
4. /
5. collectiveaccess/service-wrapper

ActiveLibrary[API Development](/categories/api)

collectiveaccess/service-wrapper
================================

A simple PHP wrapper for the CollectiveAccess web service API

1.1.5(3y ago)218.9k↑108.3%GPL-3.0-or-laterPHPPHP &gt;=7.2

Since Mar 3Pushed 2y ago5 watchersCompare

[ Source](https://github.com/CollectiveAccessProject/collectiveaccess-php)[ Packagist](https://packagist.org/packages/collectiveaccess/service-wrapper)[ Docs](https://www.collectiveaccess.org)[ RSS](/packages/collectiveaccess-service-wrapper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)DependenciesVersions (8)Used By (0)

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

[](#a-simple-php-wrapper-for-the-collectiveaccess-json-based-rest-web-service-api)

Please visit  for more information and refer to  for detailed information on the service API and other features of the core software.

### Basic usage

[](#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:

```
$client = new CollectiveAccessService\ItemService("http://localhost/","ca_objects","GET",1);
$result = $client->request();
print_r($result->getRawData());
```

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:

```
$vo_client = new CollectiveAccessService\ModelService("http://localhost/","ca_entities");
$vo_client->setRequestBody(array("types" => array("corporate_body")));
$vo_result = $vo_client->request();

$vo_result->isOk() ? print_r($vo_result->getRawData()) : print_r($vo_result->getErrors());
```

```
$vo_client = new CollectiveAccessService\SearchService("http://localhost/","ca_objects","*");
$vo_client->setRequestBody(array(
	"bundles" => array(
		"ca_objects.access" => array("convertCodesToDisplayText" => true),
		"ca_objects.status" => array("convertCodesToDisplayText" => true),
		"ca_entities.preferred_labels.displayname" => array("returnAsArray" => true)
	)
));
$vo_result = $vo_client->request();

$vo_result->isOk() ? print_r($vo_result->getRawData()) : print_r($vo_result->getErrors());
```

### Authentication

[](#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:

```
define('__CA_SERVICE_API_USER__', 'administrator');
define('__CA_SERVICE_API_KEY__', 'dublincore');

$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_result = $o_service->request();
```

You can also use a simple setter:

```
$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_service->setCredentials('administrator', 'dublincore');
$o_result = $o_service->request();
```

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`

```
$o_service = new CollectiveAccessService\ItemService('http://localhost', 'ca_objects', 'GET', 1);
$o_result = $o_service->request();
```

Then running something like this in a terminal should work:

```
export CA_SERVICE_API_USER=administrator
export CA_SERVICE_API_KEY=dublincore
php authtest.php
```

To do this in a web server setting, you could look into [apache's mod\_env](http://httpd.apache.org/docs/2.4/mod/mod_env.html).

### Retrying failed connections

[](#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:

```
$client = new CollectiveAccessService\ItemService("http://localhost/","ca_objects","GET",1);
$result = $client->setRetries(5)->setRetryDelay(2000)->request();
print_r($result->getRawData());
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~501 days

Recently: every ~417 days

Total

6

Last Release

1222d ago

PHP version history (3 changes)v1.1PHP &gt;=5.4.0

1.1.2PHP &gt;=5.6.0

1.1.4PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/cb6b3df7b0c87a2ad84265b1f55a3f721aad2c1d3d6845c7badc41efd6c6d5a5?d=identicon)[collectiveaccess](/maintainers/collectiveaccess)

---

Top Contributors

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

---

Tags

collectiveaccessprovidence

### Embed Badge

![Health badge](/badges/collectiveaccess-service-wrapper/health.svg)

```
[![Health](https://phpackages.com/badges/collectiveaccess-service-wrapper/health.svg)](https://phpackages.com/packages/collectiveaccess-service-wrapper)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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