PHPackages                             haveapi/client - 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. haveapi/client

ActiveLibrary[API Development](/categories/api)

haveapi/client
==============

A client for HaveAPI based APIs

0.29.0(today)0783↑318.8%MITPHPPHP &gt;=8.0.0

Since Jul 24Pushed 1mo ago5 watchersCompare

[ Source](https://github.com/vpsfreecz/haveapi-client-php)[ Packagist](https://packagist.org/packages/haveapi/client)[ Docs](https://github.com/vpsfreecz/haveapi-client-php)[ RSS](/packages/haveapi-client/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (18)Versions (45)Used By (0)

haveapi-client-php
==================

[](#haveapi-client-php)

haveapi-client-php is a PHP client for [HaveAPI](https://github.com/vpsfreecz/haveapi) based APIs.

Requirements
------------

[](#requirements)

- PHP &gt;= 7.4
- [Httpful](http://phphttpclient.com/)

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

[](#installation)

haveapi-client-php can be installed with composer, add `haveapi/client` to your `composer.json`:

```
{
	"require": {
		"haveapi/client": "*"
	}
}

```

You can also clone this repository and use a PSR-4 compatible autoloader, or include `bootstrap.php`, which loads all necessary classes. When using the repository, you have to install Httpful yourself.

Usage
-----

[](#usage)

First check out the API documentation, see how it works and what resources/actions are available.

Create a client instance:

```
$api = new \HaveAPI\Client("http://your.api.tld");

```

Authenticate with HTTP basic:

```
$api->authenticate('basic', ['user' => 'yourname', 'password' => 'password']);

```

Authenticate with token:

```
$api->authenticate('token', ['user' => 'yourname', 'password' => 'password']);

```

When using the token authentication, it is usually necessary to save the token for later use:

```
$token = $api->getAuthenticationProvider()->getToken();

```

Next time, authenticate with the previously received token:

```
$api->authenticate('token', ['token' => $token]);

```

### Access resources and actions as array indexes

[](#access-resources-and-actions-as-array-indexes)

```
$api['vps']['index']->call();
$api['vps']['show']->call(101);

```

or

```
$api['vps.index']->call();
$api['vps.show']->call(101);

```

### Access resources and actions as properties/methods

[](#access-resources-and-actions-as-propertiesmethods)

```
$api->vps->list();

```

Arguments can be supplied to resources and/or to the action.

```
$api->vps->find(101);
$api->vps->ip_address->delete(101, 10);

$api->vps(101)->find();
$api->vps(101)->ip_address(10)->delete();
$api->vps(101)->ip_address->delete(10);

```

### Parameters

[](#parameters)

Parameters are given as an array to action. It is the last argument given to action. Object IDs must be in front of it.

```
$api->vps->create([
	'hostname' => 'myhostname',
	'template' => 1
]);

$api->vps->ip_address->create(101, ['version' => 4]);
$api->vps(101)->ip_address->create(['version' => 4]);

```

### Object-like behaviour

[](#object-like-behaviour)

Fetch existing resource:

```
$vps = $api->vps->find(101);
echo $vps->id . "";
echo $vps->hostname . "";
$vps->hostname = 'gotcha';
$vps->save();

```

Create a new instance:

```
$vps = $api->vps->newInstance();
$vps->hostname = 'new vps';
$vps->save();
echo $vps->id . "";

```

List of resources:

```
$vpses = $api->vps->list();

foreach($vpses as $vps) {
	echo $vps->id ." = ". $vps->hostname ."";
}

```

### Response

[](#response)

If the action does not return object or object list, `\HaveAPI\Client\Response` class is returned instead.

```
$vps = $api->vps->find(101);
$response = $vps->custom_action();

print_r($response->getResponse());

```

Parameters can be accessed directly as:

```
echo $response['hostname'];

```

### Error handling

[](#error-handling)

If an action fails, exception `\HaveAPI\Client\Exception\ActionFailed` is thrown. Authentication errors result in exception `\HaveAPI\Client\Exception\AuthenticationFailed`.

```
try {
	$api->vps->create();

} catch(\HaveAPI\Client\Exception\ActionFailed $e) {
	echo $e->getMessage();
	print_r($e->getErrors());
}

```

When trying to access a resource or an action that does not exist, `\HaveAPI\Client\Exception\ObjectNotFound` is thrown. Also, invoking an action without all necessary arguments (object IDs) results in `\HaveAPI\Client\Exception\UnresolvedArguments` exception.

All exceptions thrown by the client are a subclass of `\HaveAPI\Client\Exception\Base`.

Documentation
-------------

[](#documentation)

License
-------

[](#license)

haveapi-client-php is released under the MIT license.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity71

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

Recently: every ~10 days

Total

42

Last Release

0d ago

PHP version history (3 changes)0.3.0PHP &gt;=5.3.0

0.14.2PHP &gt;=7.4.0

0.16.2PHP &gt;=8.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33817037?v=4)[Aither](/maintainers/aither)[@aither](https://github.com/aither)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/haveapi-client/health.svg)

```
[![Health](https://phpackages.com/badges/haveapi-client/health.svg)](https://phpackages.com/packages/haveapi-client)
```

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[showdoc/showdoc

ShowDoc is a tool greatly applicable for an IT team to share documents online

12.8k7.1k](/packages/showdoc-showdoc)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

751291.4k43](/packages/civicrm-civicrm-core)[atymic/twitter

Twitter API for PHP &amp; Laravel

951592.7k2](/packages/atymic-twitter)[dcblogdev/laravel-microsoft-graph

A Laravel Microsoft Graph API (Office365) package

171327.3k4](/packages/dcblogdev-laravel-microsoft-graph)[xeroapi/xero-php-oauth2

Xero official PHP SDK for oAuth2 generated with OpenAPI spec 3

1054.7M18](/packages/xeroapi-xero-php-oauth2)

PHPackages © 2026

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