2017 © Pedro Peláez
 

library shared

The shared library for other phossa2 libraries

image

phossa2/shared

The shared library for other phossa2 libraries

  • Monday, January 16, 2017
  • by phossa2
  • Repository
  • 1 Watchers
  • 4 Stars
  • 21,854 Installations
  • PHP
  • 14 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 30 Versions
  • 13 % Grown

The README.md

phossa2/shared

Build Status Code Quality Code Climate PHP 7 ready HHVM Latest Stable Version License, (*1)

phossa2/shared is the shared library for other phossa2 libraries., (*2)

It requires PHP 5.4, supports PHP 7.0+ and HHVM. It is compliant with PSR-1, PSR-2, PSR-4., (*3)

Installation

Install via the composer utility., (*4)

composer require "phossa2/shared=2.*"

or add the following lines to your composer.json, (*5)

{
    "require": {
       "phossa2/shared": "2.*"
    }
}

Features

  • Exception, (*6)

    All phossa2 exceptions implement Phossa2\Shared\Exception\ExceptionInterface., (*7)

    To implment phossa2 exception interface,, (*8)

    <?php
    namespace Phossa2\Cache\Exception;
    
    use Phossa2\Shared\Exception\ExceptionInterface;
    
    class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface
    {
    }
    
  • Message, (*9)

    Phossa2\Shared\Message\Message class is the base class for all message classes in all phossa2 packages., (*10)

    • Define package related Message class

    Message class is used to convert message code into human-readable messages, and MUST define its own property $messages., (*11)

    <?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., (*12)

    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., (*13)

    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, (*14)

    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, (*15)

    Some useful utilities here., (*16)

    • ClassNameTrait

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

    • StaticAbstract

    Used to be extended by other STATIC classes., (*18)

    <?php
    namespace Phossa2\MyPackage;
    
    class MyStaticClass extends \Phossa2\Shared\Base\StaticAbstract
    {
        ...
    }
    
  • **Trait*, (*19)

    Some useful traits in the Aware/ directory, (*20)

    • TagAwareTrait adding tag support
  • Interface, (*21)

    Some useful interfaces are in the Contract/ directory., (*22)

    • ArrayableInterface
  • Support PHP 5.4+, PHP 7.0+, HHVM, (*23)

  • PHP7 ready for return type declarations and argument type declarations., (*24)

  • PSR-1, PSR-2, PSR-4 compliant., (*25)

  • Decoupled packages can be used seperately without the framework., (*26)

Change log

Please see CHANGELOG from more information., (*27)

Testing

$ composer test

Contributing

Please see CONTRIBUTE for more information., (*28)

Dependencies

  • PHP >= 5.4.0

License

MIT License, (*29)

The Versions

16/01 2017

dev-master

9999999-dev https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

framework php library phossa phossa2

08/01 2017

2.0.28

2.0.28.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

framework php library phossa phossa2

24/08 2016

2.0.27

2.0.27.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

 

framework php library phossa phossa2

23/08 2016

2.0.26

2.0.26.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

 

framework php library phossa phossa2

17/08 2016

2.0.25

2.0.25.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

15/08 2016

2.0.24

2.0.24.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

05/08 2016

2.0.23

2.0.23.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

26/07 2016

2.0.22

2.0.22.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

22/07 2016

2.0.21

2.0.21.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

20/07 2016

2.0.20

2.0.20.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

17/07 2016

2.0.18

2.0.18.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

17/07 2016

2.0.19

2.0.19.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

17/07 2016

2.0.17

2.0.17.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

16/07 2016

2.0.16

2.0.16.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

15/07 2016

2.0.15

2.0.15.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

12/07 2016

2.0.14

2.0.14.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

10/07 2016

2.0.13

2.0.13.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

04/07 2016

2.0.12

2.0.12.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

01/07 2016

2.0.11

2.0.11.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

30/06 2016

2.0.10

2.0.10.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

28/06 2016

2.0.9

2.0.9.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

27/06 2016

2.0.8

2.0.8.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

24/06 2016

2.0.7

2.0.7.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

24/06 2016

2.0.6

2.0.6.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

24/06 2016

2.0.5

2.0.5.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

23/06 2016

2.0.4

2.0.4.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

22/06 2016

2.0.3

2.0.3.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

22/06 2016

2.0.2

2.0.2.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

17/06 2016

2.0.1

2.0.1.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2

16/06 2016

2.0.0

2.0.0.0 https://github.com/phossa2/shared

The shared library for other phossa2 libraries

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

framework php library phossa phossa2