1. Go to this page and download the library: Download wearesho-team/yii-http 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/ */
wearesho-team / yii-http example snippets
namespace App\Views;
use Wearesho\Yii\Http\View;
class EntityView extends View {
/** @var string */
protected $foo;
/** @var \SomeClass */
protected $dependency;
public function __construct(string $foo, \SomeClass $dependency) {
$this->foo = $foo;
$this->dependency = $dependency;
}
protected function renderInstantiated(): array {
return [
'bar' => $this->foo,
];
}
}
use App\Views\EntityView;
$argument = 'foo';
$output = EntityView::render($argument);
print_r($output);
/**
* Will output:
* Array
(
[bar] => 1
)
*/
// or if you have multiple data
$arguments = [
'1',
'2',
];
$output = EntityView::multiple($arguments);
/**
* Will output
* Array
(
[0] => Array
(
[bar] => 1
)
[1] => Array
(
[bar] => 2
)
)
*/