PHPackages                             trunglv/protocol - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. trunglv/protocol

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

trunglv/protocol
================

The Hoa\\Protocol library. \[Trunglv Maintenance\]

02PHP

Since May 13Pushed 2y agoCompare

[ Source](https://github.com/trunglv/Protocol)[ Packagist](https://packagist.org/packages/trunglv/protocol)[ RSS](/packages/trunglv-protocol/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

 [![Hoa](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)](https://camo.githubusercontent.com/2b5c32c5d4bc5e9298821b22d364a522e2dbc0295c1c011b1f9f86a4d07df07e/68747470733a2f2f7374617469632e686f612d70726f6a6563742e6e65742f496d6167652f486f612e737667)

---

 [![Build status](https://camo.githubusercontent.com/11bacb0a8f13848e6576d2eaa3ce5ad46c8d59c7dbc8fccb66695991ddecdc03/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f686f6170726f6a6563742f50726f746f636f6c2f6d61737465722e737667)](https://travis-ci.org/hoaproject/Protocol) [![Code coverage](https://camo.githubusercontent.com/5cd0ec4ad1b83e55de514f737639a6932fa5e9de319cb27278bc81a02c236d30/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f686f6170726f6a6563742f50726f746f636f6c2f6d61737465722e737667)](https://coveralls.io/github/hoaproject/Protocol?branch=master) [![Packagist](https://camo.githubusercontent.com/944b77a1d954c33c19c67022771323a4c307d71565dc9ffd7f49c2b6d4da846e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f686f612f70726f746f636f6c2e737667)](https://packagist.org/packages/hoa/protocol) [![License](https://camo.githubusercontent.com/946fbb1d053c99c8e9eecca85e3af00529dbfdbd2f58f61ffb1623ac956667f9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f686f612f70726f746f636f6c2e737667)](https://hoa-project.net/LICENSE)

 Hoa is a **modular**, **extensible** and **structured** set of PHP libraries.
 Moreover, Hoa aims at being a bridge between industrial and research worlds.

Hoa\\Protocol
=============

[](#hoaprotocol)

[![Help on IRC](https://camo.githubusercontent.com/4dbc9c9d28c30cf1ab591f4bb8212fe4dbddc734145df532a9bb86b09878d4c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d253233686f6170726f6a6563742d6666303036362e737667)](https://webchat.freenode.net/?channels=#hoaproject)[![Help on Gitter](https://camo.githubusercontent.com/8c4c85951788ff606b1268cb3dd946be05e3054795455d0a7b9250711bc2ac05/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f68656c702d6769747465722d6666303036362e737667)](https://gitter.im/hoaproject/central)[![Documentation](https://camo.githubusercontent.com/7059ad5f1a363f9098686c59d432f01d7330aed9d4b6c8111d985fd64cfc6c60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f646f63756d656e746174696f6e2d6861636b5f626f6f6b2d6666303036362e737667)](https://central.hoa-project.net/Documentation/Library/Protocol)[![Board](https://camo.githubusercontent.com/fd81654ba14b3aca3a713e1b471bc3fc3ba7b5bb3761ccffd6eea2e2ed1fa5ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f7267616e69736174696f6e2d626f6172642d6666303036362e737667)](https://waffle.io/hoaproject/protocol)

This library provides the `hoa://` protocol, which is a way to abstract resource accesses.

[Learn more](https://central.hoa-project.net/Documentation/Library/Protocol).

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

[](#installation)

With [Composer](https://getcomposer.org/), to include this library into your dependencies, you need to require [`hoa/protocol`](https://packagist.org/packages/hoa/protocol):

```
$ composer require hoa/protocol '~2.0'
```

For more installation procedures, please read [the Source page](https://hoa-project.net/Source.html).

Testing
-------

[](#testing)

Before running the test suites, the development dependencies must be installed:

```
$ composer install
```

Then, to run all the test suites:

```
$ vendor/bin/hoa test:run
```

For more information, please read the [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html).

Quick usage
-----------

[](#quick-usage)

We propose a quick overview of how to list the current tree of the protocol, how to resolve a `hoa://` path and finally how to add a new node in this tree.

### Explore resources

[](#explore-resources)

First of all, to get the instance of the `hoa://` protocol, you should use the static `getInstance` method on the `Hoa\Protocol\Protocol` class which represents the root of the protocol tree:

```
echo Hoa\Protocol\Protocol::getInstance();

/**
 * Might output:
 *   Application
 *     Public
 *   Data
 *     Etc
 *       Configuration
 *       Locale
 *     Lost+found
 *     Temporary
 *     Variable
 *       Cache
 *       Database
 *       Log
 *       Private
 *       Run
 *       Test
 *   Library
 */
```

We see that there is 3 “sub-roots”:

1. `Application`, representing resources of the application, like public files (in the `Public` node), models, resources… everything related to the application,
2. `Data`, representing data required by the application, like configuration files, locales, databases, tests etc.
3. `Library`, representing all Hoa's libraries.

Thus, `hoa://Library/Protocol/README.md` represents the abstract path to this real file. No matter where you are on the disk, this path will always be valid and pointing to this file. This becomes useful in an application where you would like to access to a configuration file like this `hoa://Data/Etc/Configuration/Foo.php`: Maybe the `Data` directory does not exist, maybe the `Etc` or `Configuration` directories do not exist neither, but each node of the `hoa://` tree resolves to a valid directory which contains your `Foo.php` configuration file. This is an **abstract path for a resource**.

### Resolving a path

[](#resolving-a-path)

We can either resolve a path by using the global `resolve` function or the `Hoa\Protocol\Protocol::resolve` method:

```
var_dump(
    resolve('hoa://Library/Protocol/README.md')
);

/**
 * Might output:
 *     string(37) "/usr/local/lib/Hoa/Protocol/README.md"
 */
```

### Register new nodes in the tree

[](#register-new-nodes-in-the-tree)

The `hoa://` protocol is a tree. Thus, to add a new “component”/“directory” in this tree, we must create a node and register it as a child of an existing node. Thus, in the following example we will create a `Usb` node, pointing to the `/Volumes` directory, and we will add it as a new sub-root, so an immediate child of the root:

```
$protocol   = Hoa\Protocol\Protocol::getInstance();
$protocol[] = new Hoa\Protocol\Node('Usb', '/Volumes/');
```

Here we are. Now, resolving `hoa://Usb/StickA` might point to `/Volumes/StickA`(if exists):

```
var_dump(
    resolve('hoa://Usb/StickA')
);

/**
 * Might output:
 *     string(15) "/Volumes/StickA"
 */
```

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

[](#documentation)

The [hack book of `Hoa\Protocol`](https://central.hoa-project.net/Documentation/Library/Protocol)contains detailed information about how to use this library and how it works.

To generate the documentation locally, execute the following commands:

```
$ composer require --dev hoa/devtools
$ vendor/bin/hoa devtools:documentation --open
```

More documentation can be found on the project's website: [hoa-project.net](https://hoa-project.net/).

Getting help
------------

[](#getting-help)

There are mainly two ways to get help:

- On the [`#hoaproject`](https://webchat.freenode.net/?channels=#hoaproject)IRC channel,
- On the forum at [users.hoa-project.net](https://users.hoa-project.net).

Contribution
------------

[](#contribution)

Do you want to contribute? Thanks! A detailed [contributor guide](https://hoa-project.net/Literature/Contributor/Guide.html) explains everything you need to know.

License
-------

[](#license)

Hoa is under the New BSD License (BSD-3-Clause). Please, see [`LICENSE`](https://hoa-project.net/LICENSE) for details.

###  Health Score

13

—

LowBetter than 1% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 84.5% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/15e9d0c7c6322100e7f10b8efb4ed2a28193b52d7ba32d96033635838c7c09f0?d=identicon)[trunglv](/maintainers/trunglv)

---

Top Contributors

[![Hywan](https://avatars.githubusercontent.com/u/946104?v=4)](https://github.com/Hywan "Hywan (49 commits)")[![trunglv](https://avatars.githubusercontent.com/u/820411?v=4)](https://github.com/trunglv "trunglv (4 commits)")[![Grummfy](https://avatars.githubusercontent.com/u/668804?v=4)](https://github.com/Grummfy "Grummfy (2 commits)")[![vonglasow](https://avatars.githubusercontent.com/u/1275202?v=4)](https://github.com/vonglasow "vonglasow (2 commits)")[![Metalaka](https://avatars.githubusercontent.com/u/5406767?v=4)](https://github.com/Metalaka "Metalaka (1 commits)")

### Embed Badge

![Health badge](/badges/trunglv-protocol/health.svg)

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

###  Alternatives

[symfony/expression-language

Provides an engine that can compile and evaluate expressions

2.9k208.2M1.4k](/packages/symfony-expression-language)[ergebnis/composer-normalize

Provides a composer plugin for normalizing composer.json.

1.1k37.3M2.1k](/packages/ergebnis-composer-normalize)[ua-parser/uap-php

A multi-language port of Browserscope's user agent parser.

55734.7M69](/packages/ua-parser-uap-php)[illuminate/container

The Illuminate Container package.

31278.1M2.0k](/packages/illuminate-container)[composer/class-map-generator

Utilities to scan PHP code and generate class maps.

197122.6M108](/packages/composer-class-map-generator)

PHPackages © 2026

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