1. Go to this page and download the library: Download vanilla/garden-hydrate 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/ */
vanilla / garden-hydrate example snippets
$spec = [
'$hydrate' => 'sprintf',
'format' => 'Hello %s',
'args' => [
'World'
]
];
$hydrator = new DataHydrator();
$result = $hydrator->resolve($spec);
// $result will be 'Hello World'
use Garden\Hydrate\Resolvers\FunctionResolver;
use \Garden\Hydrate\DataHydrator;
$hydrator = new DataHydrator();
$lcase = new FunctionResolver(function (string $string) {
return strtolower($string);
});
$hydrator->addResolver($lcase);
$r = $hydrator->resolve([
'@hydrate' => 'lcase',
'string' => 'STOP YELLING'
]);
// $r will be "stop yelling"
class WidgetExceptionHandler implements ExceptionHandlerInterface {
public function handleException(\Throwable $ex, array $data, array $params) {
if (isset($data['$widget'])) {
// If we are on a node that represents a widget then replace that widget with an error widget.
return ['$widget' => 'error-message', 'message' => $ex->getMessage()];
} else {
// This isn't a widget node. Best to throw the exception to be caught by a parent widget node.
throw $ex;
}
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.