PHP code example of jeyroik / extas-expands
1. Go to this page and download the library: Download jeyroik/extas-expands 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/ */
jeyroik / extas-expands example snippets
use extas\components\Item;
use extas\components\expands\Expand;
/**
* @var Psr\Http\Message\RequestInterface $request
* @var Psr\Http\Message\ResponseInterface $response
*/
$app = new class([
'name' => 'example app'
]) extends Item {
protected function getSubjectForExtension() : string{
return 'app';
}
};
$expand = new Expand([
Expand::FIELD__PSR_REQUEST => $request,
Expand::FIELD__PSR_RESPONSE => $response,
Expand::FIELD__ARGUMENTS => [
Expand::ARG__EXPAND => 'app.version'
]
]);
$app = $expand->expand($app);
use extas\components\Item;
use extas\components\expands\Expand;
/**
* @var Psr\Http\Message\RequestInterface $request
* @var Psr\Http\Message\ResponseInterface $response
*/
$app = new class([
'name' => 'example app'
]) extends Item {
protected function getSubjectForExtension() : string{
return 'app';
}
};
$expand = new Expand([
Expand::FIELD__PSR_REQUEST => $request,
Expand::FIELD__PSR_RESPONSE => $response,
Expand::FIELD__ARGUMENTS => [
Expand::ARG__EXPAND => 'app.version'
]
]);
$app = $expand->expand($app);
print_r($app->__toArray());
Array
(
"name" => "example app"
"version" => "1.0"
"expand" => ["app.version", "app.player"]
)