3 Star 0 Fork 0

Gitee 极速下载 / hoa

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/hoaproject/Core
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Hoa

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

Hoa\Core state

This library is the foundation —the core— of all libraries of Hoa. It provides fundamental algorithms, paradigms and mechanisms, organized as follows:

  • Core: core of the core;
  • Consistency: adds consistency to PHP (from/import, xcallable, dnew, curry etc.);
  • Exception: homogenises exceptions and errors;
  • Protocol: abstracts resources —and more— accesses (e.g. hoa://Library or hoa://Application);
  • Parameter: manages parameters of libraries;
  • Event: adds support of events and listeners;
  • Data: adds support of polymorphic data with high performance.

Warning

This library is deprecated. It has been splitted into:

This library is no longer used.

Installation

The core can be placed where you want. We recommand /usr/local/lib/Hoa for Unix-like systems and C:\Program Files\Hoa for Windows systems.

Then, you have to require Core.php and it is enough to use all libraries of Hoa; thus:

<?php

require '/usr/local/lib/Hoa/Core/Core.php';
var_dump(HOA); // bool(true)

With Composer, you do not need to require Core.php, only vendor/autoload.php as usual.

Quick usage

We propose a quick overview of some layers of the core.

Exceptions and errors

Errors are unified to exceptions. Exceptions are of 3 kinds: idle, normal and error. They support formatted messages, auto-catch, dedicated event channel etc.

Protocol

hoa:// defines an abstraction for application ressources (with roots Data and Application) and another abstraction for libraries resources (with root Library). For example:

$conf = require 'hoa://Data/Etc/Configuration/Foo.php';

We can attach more than resources on this protocol. Example with the Hoa\Registry library:

Hoa\Registry\Registry::set('foo', 'bar');
echo resolve('hoa://Library/Registry#foo'); // bar

Events and listeners

Libraries can use events and listeners (which have some similarities). For example, if we attach a function to the channel of exceptions:

event('hoa://Event/Exception')->attach(function ($bucket) {
    $exception = $bucket->getData();
    echo 'Exception: ', $exception->getMessage(), "\n";
})

throw new Hoa\Core\Exception('Hello %s!', 0, 'Gordon');
// Exception: Hello Gordon!

Some libraries define their own channels, such as the Hoa\Stream library with, for example, hoa://Event/Stream/<stream-name>:close-before, or hoa://Event/Log/<channel> etc.

For listeners, we are closer to the emitter:

$websocket = new Hoa\Websocket\Server(
    new Hoa\Socket\Server('tcp://127.0.0.1:8889')
);
$websocket->on('message', $callable);
$websocket->run();

Documentation

Different documentations can be found on the website: http://hoa-project.net/.

License

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

空文件

简介

暂无描述 展开 收起
PHP
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mirrors/hoa.git
git@gitee.com:mirrors/hoa.git
mirrors
hoa
hoa
master

搜索帮助