PHPackages                             jmeyering/hal-explorer - 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. jmeyering/hal-explorer

ActiveLibrary[API Development](/categories/api)

jmeyering/hal-explorer
======================

HalExplorer is a php client for exploring HAL Hateoas apis. HalExplorer is able to craft requests and follow links to resource relationships.

1.5.0(9y ago)1621.5k5[1 PRs](https://github.com/Jmeyering/hal-explorer/pulls)MITPHPPHP &gt;=5.5.0

Since Aug 4Pushed 4y ago1 watchersCompare

[ Source](https://github.com/Jmeyering/hal-explorer)[ Packagist](https://packagist.org/packages/jmeyering/hal-explorer)[ RSS](/packages/jmeyering-hal-explorer/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (4)Versions (11)Used By (0)

hal-explorer: Hateoas Api explorer.
===================================

[](#hal-explorer-hateoas-api-explorer)

[![Build Status](https://camo.githubusercontent.com/e3d229d7767501739cca02ded8f7ad64ac53035cc59fd959f75752e963a9c8de/68747470733a2f2f7472617669732d63692e6f72672f4a6d65796572696e672f68616c2d6578706c6f7265722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Jmeyering/hal-explorer)[![Code Climate](https://camo.githubusercontent.com/ded498d7f1af5c591dddaae7ca3bdbc8fff78f077c8d56b4c7947dba007a4064/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f4a6d65796572696e672f68616c2d6578706c6f7265722f6261646765732f6770612e737667)](https://codeclimate.com/github/Jmeyering/hal-explorer)

HalExplorer is a php client useful for exploring [HAL](http://stateless.co/hal_specification.html) formatted apis. HalExplorer is able to craft requests and follow links to retreive, create, update and delete resource relationships.

The codebase is fully covered by phpspec and extensively documented.

Install
-------

[](#install)

`composer require jmeyering/hal-explorer`

\##Docs

[readthedocs](http://hal-explorer.readthedocs.org/en/latest/)

Api Documentation
-----------------

[](#api-documentation)

To generate api documentation use whatever phpdoc generation tool you want but apigen is included with the composer deps. Just run `vendor/bin/apigen generate` to create the documentation, then point your browser to `public/index.html` to view.

PSR7
----

[](#psr7)

The library makes exclusive use of [PSR7 messages](http://www.php-fig.org/psr/psr-7). Whatever http client is used internally must return PSR7 Message interfaces.

Usage
-----

[](#usage)

To use the exploration feature of the library we need to think about our responses and their included `_links` as objects and relationships.

Fetching, Creating, Updating, and Deleting are the primary actions to perform on a related object. HalExplorer exposes this functionality with the `getRelation`, `createRelation`, `updateRelation`, `patchUpdateRelation` and `deleteRelation` methods.

As expected, these methods map to the `GET`, `POST`, `PUT`, `PATCH` and `DELETE` HTTP verbs.

```
$explorer->createRelation($object, "association");
```

Example
-------

[](#example)

We will use the [haltalk](http://haltalk.herokuapp.com/explorer/browser.html) api as an endpoint example and guzzlehttp/guzzle for our HTTP Client.

```
// This Example creates a new account with haltalk and creates a post from that
// account.
$client = new \GuzzleHttp\Client();
$explorer = new \HalExplorer\Explorer();
$adapter = new \HalExplorer\ClientAdapters\Adapter();

$adapter->setClient($client);
$explorer->setAdapter($adapter)->setBaseUrl("http://haltalk.herokuapp.com");

// The haltalk api requires both "application/hal+json" and, application/json"
// Accept headers to work. hal-explorer only adds "application/hal+json" by
// default so we need to override this default value.
$explorer->setDefaults(function($original){
    $original["headers"]["Accept"] = "application/hal+json, application/json";

    return $original;
});

$username = "myuniqueusername";

// Enter the haltalk api and return a PSR7 ResponseInterface
$entrypoint = $explorer->enter();

// Create an account with haltalk.
$accountResponse = $explorer->createRelation($entrypoint, "signup", [
    "body" => '{
        "username": "'.$username.'",
        "password": "password"
    }'
]);

// Retreive my account information using thy "me" link on the entrypoint.
// Because this is a templated link, we must pass templated data along.
$myAccount = $explorer->getRelation($entrypoint, "me", [
    "template" => [
        "name" => $username,
    ],
]);

// Create a post from my account. This resource requires basic auth.
$post = $explorer->createRelation($myAccount, "posts", [
    "body" => '{
        "content": "This is my post Content"
    }',
    "auth" => [
        $username,
        "password"
    ]
]);

// Haltalk return the post location in a response header. We can fetch that
// information using the PSR7 method, getHeaderLine()
$postLocation = $post->getHeaderLine("location");
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity64

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

Recently: every ~13 days

Total

10

Last Release

3543d ago

### Community

Maintainers

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

---

Top Contributors

[![Jmeyering](https://avatars.githubusercontent.com/u/5166603?v=4)](https://github.com/Jmeyering "Jmeyering (33 commits)")

### Embed Badge

![Health badge](/badges/jmeyering-hal-explorer/health.svg)

```
[![Health](https://phpackages.com/badges/jmeyering-hal-explorer/health.svg)](https://phpackages.com/packages/jmeyering-hal-explorer)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M738](/packages/sylius-sylius)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[telnyx/telnyx-php

Official Telnyx PHP SDK — APIs for Voice, SMS, MMS, WhatsApp, Fax, SIP Trunking, Wireless IoT, Call Control, and more. Build global communications on Telnyx's private carrier-grade network.

35789.4k2](/packages/telnyx-telnyx-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tempest/framework

The PHP framework that gets out of your way.

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

PHPackages © 2026

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