1. Go to this page and download the library: Download phossa/phossa-shared library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phossa / phossa-shared example snippets
namespace Phossa\Cache\Exception;
class BadMethodCallException extends
\Phossa\Shared\Exception\BadMethodCallException
{
}
use Phossa\Cache\Message\Message;
...
// throw exception
throw new Exception\RuntimeException(
Message::get(Message::CACHE_DRIVER_FAIL, get_class($driver)),
Message::CACHE_DRIVER_FAIL
);
namespace Phossa\Cache;
use Phossa\Shared\Message\Loader\LanguageLoader;
// set language to 'zh_CN'
$langLoader = new LanguageLoader('zh_CN');
// will load local `Message\Message.zh_CN.php` language file
Message\Message::setLoader($langLoader);
// print message in chinese
echo Message\Message::get(
Message::CACHE_MESSAGE, get_class($object)
);
namespace Phossa\Cache;
use Phossa\Shared\Message\Formatter\HtmlFormatter;
// format message as HTML
$formatter = new HtmlFormatter();
Message\Message::setFormatter($formatter);
// print as HTML
echo Message\Message::get(
Message::CACHE_MESSAGE, get_class($object)
);
namespace Phossa\MyPackage;
class MyStaticClass extends SomeClass
{
use \Phossa\Shared\Pattern\StaticTrait;
...
}
namespace Phossa\MyPackage;
class MyStaticClass extends \Phossa\Shared\Pattern\StaticAbstract
{
...
}
namespace Phossa\MyPackage;
class MySingletonClass extends SomeClass
{
use \Phossa\Shared\Pattern\SingletonTrait;
...
}
$obj = MySingletonClass::getInstance();
namespace Phossa\MyPackage;
class MyNewSingletonClass extends MySingletonClass
{
...
}
namespace Phossa\Event;
use Phossa\Shared\Pattern\ShareableInterface;
class EventManager implements ShareableInterface
{
use \Phossa\Shared\Pattern\ShareableTrait;
...
}
// global event manager instance
$globalEM = EventManager::getShareable();
// local event manager
$localEM = new EventManager();
// this EM global ?
if ($globalEM->isShareable()) {
...
} else {
...
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.