phossa2/shared
Composer 安装命令:
composer require phossa2/shared
包简介
The shared library for other phossa2 libraries
README 文档
README
phossa2/shared is the shared library for other phossa2 libraries.
It requires PHP 5.4, supports PHP 7.0+ and HHVM. It is compliant with PSR-1, PSR-2, PSR-4.
Installation
Install via the composer utility.
composer require "phossa2/shared=2.*"
or add the following lines to your composer.json
{
"require": {
"phossa2/shared": "2.*"
}
}
Features
-
Exception
All phossa2 exceptions implement
Phossa2\Shared\Exception\ExceptionInterface.To implment phossa2 exception interface,
<?php namespace Phossa2\Cache\Exception; use Phossa2\Shared\Exception\ExceptionInterface; class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface { }
-
Message
Phossa2\Shared\Message\Messageclass is the base class for all message classes in all phossa2 packages.-
Define package related
MessageclassMessage class is used to convert message code into human-readable messages, and MUST define its own property
$messages.<?php namespace Phossa2\Cache\Message; use Phossa2\Shared\Message\Message; class CacheMessage extends Message { // use current year_month_date_hour_minute const CACHE_MESSAGE = 1512220901; // driver failed const CACHE_DRIVER_FAIL = 1512220902; protected static $messages = [ self::CACHE_MESSAGE => 'cache %s', self::CACHE_DRIVER_FAILT => 'cache driver %s failed', ]; }
-
Using message class
Usually only
Message::get()andMessage::CONST_VALUEare used.use Phossa2\Cache\Message\CaseMessage; ... // throw exception throw new \RuntimeException( CacheMessage::get(CacheMessage::CACHE_DRIVER_FAIL, get_class($driver)), CacheMessage::CACHE_DRIVER_FAIL );
-
Message loader
Used for loading different code to message mapping such as language files.
namespace Phossa2\Cache; use Phossa2\Cache\Message\CaseMessage; use Phossa2\Shared\Message\Loader\LanguageLoader; // set language to 'zh_CN' $langLoader = new LanguageLoader('zh_CN'); // will load `CacheMessage.zh_CN.php` in the same dir as `CacheMessage.php` CacheMessage::setLoader($langLoader); // print message in chinese echo CacheMessage::get( CacheMessage::CACHE_MESSAGE, get_class($object) );
-
Message formatter
Used for formatting messages for different devices such as HTML page. Formatter is shared among all siblings of
Phossa2\Shared\Message\Messagenamespace Phossa2\Cache; use Phossa2\Cache\Message\CaseMessage; use Phossa2\Shared\Message\Formatter\HtmlFormatter; // format message as HTML $formatter = new HtmlFormatter(); CacheMessage::setFormatter($formatter); // print as HTML echo CacheMessage::get( CacheMessage::CACHE_MESSAGE, get_class($object) );
-
-
Utility
Some useful utilities here.
-
ClassNameTraitPHP 5.4 has
::classfeature missing.ClassNameTraitprovides three static methods::getClassName(),::getShortName(),::getNameSpace() -
StaticAbstractUsed to be extended by other STATIC classes.
<?php namespace Phossa2\MyPackage; class MyStaticClass extends \Phossa2\Shared\Base\StaticAbstract { ... }
-
-
*Trait
Some useful traits in the
Aware/directoryTagAwareTraitadding tag support
-
Interface
Some useful interfaces are in the
Contract/directory.ArrayableInterface
-
Support PHP 5.4+, PHP 7.0+, HHVM
-
PHP7 ready for return type declarations and argument type declarations.
-
PSR-1, PSR-2, PSR-4 compliant.
-
Decoupled packages can be used seperately without the framework.
Change log
Please see CHANGELOG from more information.
Testing
$ composer test
Contributing
Please see CONTRIBUTE for more information.
Dependencies
- PHP >= 5.4.0
License
phossa2/shared 适用场景与选型建议
phossa2/shared 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 230.68k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2016 年 06 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「library」 「phossa」 「phossa2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phossa2/shared 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phossa2/shared 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phossa2/shared 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Inbox pattern process implementation for your Laravel Applications
Core library that defines common interfaces used by the rest of the intahwebz..
Amqp classes
Provides command to manage a web library directory
Alfabank REST API integration
统计信息
- 总下载量: 230.68k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 24
- 依赖项目数: 14
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-16