1. Go to this page and download the library: Download webiny/std-lib 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/ */
class MyClass
{
use FactoryTrait;
function myMethod()
{
// let's say we have a class we want to construct
// the class has a constructor defined like this __construct($param1, $param2)
// the class should implement \Webiny\Crypt\Bridge\CryptInterface
$class = '\SomeVendor\SomeLib\SomeClass';
try {
$classInstance = $this->factory($class, '\Webiny\Crypt\Bridge\CryptInterface', ['foo1', 'foo2']);
} catch (\Webiny\StdLib\Exception\Exception $e) {
throw $e; // the class probably doesn't implement the
class MyClass
{
use SingletonTrait;
protected function __init()
{
// this will be called only once
$this->__somePrivateMethod();
}
}
$instance = MyClass::getInstance(); // this calls the internal __init method, but only the first time, when it creates the instance
class MyClass
{
use StdObjectTrait;
public function test()
{
// create StringObject
$this->str('This is a string');
// create ArrayObject
$this->arr(['one', 'two']);
// create UrlObject
$this->url('http://www.webiny.com/');
// create DateTimeObject
$this->dateTime('now');
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.