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.27.3(2mo ago)0417↑100%MITPHPPHP &gt;=8.0.0

Since Jul 24Pushed 2mo 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 1mo ago

READMEChangelogDependencies (3)Versions (39)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

48

—

FairBetter than 95% of packages

Maintenance84

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity70

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

Recently: every ~11 days

Total

36

Last Release

81d 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 (87 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

[atymic/twitter

Twitter API for PHP &amp; Laravel

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

A Laravel Microsoft Graph API (Office365) package

168285.5k1](/packages/dcblogdev-laravel-microsoft-graph)[dcblogdev/laravel-xero

A Laravel Xero package

53129.1k1](/packages/dcblogdev-laravel-xero)[typhonius/acquia-php-sdk-v2

A PHP SDK for Acquia CloudAPI v2

222.8M7](/packages/typhonius-acquia-php-sdk-v2)[bynder/bynder-php-sdk

Bynder PHP Library

171.1M3](/packages/bynder-bynder-php-sdk)[weble/zohoclient

Zoho API Client for oAuth auth and common tasks - PHP SDK

11145.6k3](/packages/weble-zohoclient)

PHPackages © 2026

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