Giter Club home page Giter Club logo

protocol's Introduction

Hoa


Build status Code coverage Packagist 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

Help on IRC Help on Gitter Documentation Board

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

Learn more.

Installation

With Composer, to include this library into your dependencies, you need to require hoa/protocol:

$ composer require hoa/protocol '~2.0'

For more installation procedures, please read the Source page.

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.

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

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

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

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

The hack book of Hoa\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.

Getting help

There are mainly two ways to get help:

Contribution

Do you want to contribute? Thanks! A detailed contributor guide explains everything you need to know.

License

Hoa is under the New BSD License (BSD-3-Clause). Please, see LICENSE for details.

protocol's People

Contributors

grummfy avatar hywan avatar metalaka avatar vonglasow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

protocol's Issues

Dependabot can't resolve your PHP dependency files

Dependabot can't resolve your PHP dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Root composer.json requires hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - hoa/exception dev-master requires hoa/event dev-master -> found hoa/event[dev-master, 2.x-dev (alias of dev-master)] but it does not match your minimum-stability.
  Problem 2
    - Root composer.json requires hoa/test dev-master -> satisfiable by hoa/test[dev-master].
    - hoa/test dev-master requires hoa/cli dev-master -> found hoa/cli[dev-master, 3.x-dev (alias of dev-master)] but it does not match your minimum-stability.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

resolve helper in conflict with the Laravel helper resolve

Seems the issue #18 not resolve,
Can we re-open it 🙏 ?

I've write a comment on #18 but in case you don't see it because it's closed issue:

Hello, I think this issue #18 have to be re-open :/

There is a helper resolve() in .../laravel/framework/src/Illuminate/Foundation/helpers.php who conflict with yours even in a namespace :/

I have the hoa/protocol version "1.17.01.14".

hoa helper: vendor/hoa/protocol/Wrapper.php
illuminate helper: vendor/laravel/framework/src/Illuminate/Foundation/helpers.php

The problem don't come from my code but from the package hyn/multi-tenant who use the resolve helper in the Laravel way. You can see it here:
vendor/hyn/multi-tenant/src/Providers/Tenants/QueueProvider.php

What can I do to patch it?

WITH_COMPOSER constant: Make a difference between "downloaded with composer" and "autoloaded with composer"

This is related to hoaproject/Ruler#86
I'm using the Hoa/Ruler library that i downloded with composer, but i'm using a third party autoloader. When hoa://Library/Ruler/Grammar.pp gets loaded the \Hoa\Protocol\Node\Library object calls its parent in the reach function because the WITH_COMPOSER contant is false. effectivly looking into directories in a camelcase name format.
But since i used composer to download the files, Grammar.pp is not found (my directories are not camelcase)
I solved this by forcing WITH_COMPOSER to true, this constant is based on wether the Composer\Autoload\ClassLoader class exists or not.
It may be preferable to make a distinction between "downloaded with composer" (which sets a specific directory structure) from the "autoloaded_with_composer" (which imply the class present at runtime).
Then hoa://Library/Ruler/Grammar.pp should rely on the "downloaded with composer" constant to call its parent or not.
Thank you.

`hoa://Library` must look into root Composer directory if Composer

Let say we have this situation:

/Foo
    Bar.php
    Baz.php
    Test/
        Unit/
            Qux.php
    vendor/
        hoa/
            test/
                …

When we run tests, we use: vendor/bin/hoa test:run -d Test from the Foo directory. Imagine the Qux.php test suite uses hoa://Library to access a file inside vendor/hoa/. No problem! However, if it is to access a file like Bar.php or Baz.php, then it fails because hoa/protocol is installed inside vendor/hoa/.

So hoa://Library/ must look into parent-parent-parent directory too if installed with Composer. This path must be added on-the-fly.

Protocol already defined

Every time I run a composer command, I am getting the following warning:

Warning: stream_wrapper_register(): Protocol hoa:// is already defined. in vendor/hoa/protocol/Wrapper.php on line 580

How can I avoid this warning? I did not register this package on composer, it is being used as a dependency to another package. The version in use is:

hoa/protocol 1.16.01.11 The Hoa\Protocol library.

When can I get to use the latest version of hoa?

Currently when I install hoa\project via composer, it will only use hoa\protocol version 1.17.14.
Composer will throw an error. I believe below commit in master suppose to fix it.

a832ea9

Any idea when this fix will be release?

Dependabot can't resolve your PHP dependency files

Dependabot can't resolve your PHP dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Root composer.json requires hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - hoa/exception dev-master requires hoa/event dev-master -> found hoa/event[dev-master, 2.x-dev (alias of dev-master)] but it does not match your minimum-stability.
  Problem 2
    - Root composer.json requires hoa/test dev-master -> satisfiable by hoa/test[dev-master].
    - hoa/test dev-master requires hoa/cli dev-master -> found hoa/cli[dev-master, 3.x-dev (alias of dev-master)] but it does not match your minimum-stability.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

View the update logs.

Dependabot can't resolve your PHP dependency files

Dependabot can't resolve your PHP dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - hoa/exception dev-master requires hoa/event dev-master -> satisfiable by hoa/event[dev-master] but these conflict with your requirements or minimum-stability.
  Problem 2
    - Installation request for hoa/test dev-master -> satisfiable by hoa/test[dev-master].
    - hoa/test dev-master requires hoa/cli dev-master -> satisfiable by hoa/cli[dev-master] but these conflict with your requirements or minimum-stability.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Dependabot can't resolve your PHP dependency files

Dependabot can't resolve your PHP dependency files.

As a result, Dependabot couldn't update your dependencies.

The error Dependabot encountered was:

Your requirements could not be resolved to an installable set of packages.
  Problem 1
    - Installation request for hoa/exception dev-master -> satisfiable by hoa/exception[dev-master].
    - hoa/exception dev-master requires hoa/event dev-master -> satisfiable by hoa/event[dev-master] but these conflict with your requirements or minimum-stability.
  Problem 2
    - Installation request for hoa/test dev-master -> satisfiable by hoa/test[dev-master].
    - hoa/test dev-master requires hoa/cli dev-master -> satisfiable by hoa/cli[dev-master] but these conflict with your requirements or minimum-stability.

If you think the above is an error on Dependabot's side please don't hesitate to get in touch - we'll do whatever we can to fix it.

You can mention @dependabot in the comments below to contact the Dependabot team.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.