wearesho-team / yii-http
Yii2 Web Extension for internal Wearesho Team projects usage
1.16.6
2023-05-19 14:59 UTC
Requires
- php: >=7.4
- horat1us/yii2-base: ^1.8.1
- yiisoft/yii2: ~2.0.43
Requires (Dev)
- horat1us/yii2-asset-free: ^1.0.1
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.3
This package is auto-updated.
Last update: 2026-05-29 01:16:21 UTC
README
Alternative work with HTTP
Contents
View
Implement your view
<?php 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, ]; } }
then use it
<?php 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 ) ) */
GetParamsBehavior [Example]
Fills Panel attributes from \yii\web\Request::get().
Installation
composer require wearesho-team/yii-http
Add to your DI container:
<?php \Yii::$container->setSingleton( \yii\web\Response::class, \Wearesho\Yii\Http\Response::class ); \Yii::$container->set( \yii\web\ErrorHandler::class, \Wearesho\Yii\Http\ErrorHandler::class ); \Yii::$container->setSingleton(\yii\db\Connection::class);
TODO
- Documentation
- Tests
LICENSE
MIT