phossa2/shared 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

phossa2/shared

最新稳定版本:2.0.28

Composer 安装命令:

composer require phossa2/shared

包简介

The shared library for other phossa2 libraries

README 文档

README

Build Status Code Quality Code Climate PHP 7 ready HHVM Latest Stable Version License

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\Message class is the base class for all message classes in all phossa2 packages.

    • Define package related Message class

      Message 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() and Message::CONST_VALUE are 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\Message

      namespace 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.

    • ClassNameTrait

      PHP 5.4 has ::class feature missing. ClassNameTrait provides three static methods ::getClassName(), ::getShortName(), ::getNameSpace()

    • StaticAbstract

      Used 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/ directory

    • TagAwareTrait adding 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

MIT License

统计信息

  • 总下载量: 215.64k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 3
  • 依赖项目数: 14
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固