wearesho-team / yii-http
Yii2 Web 扩展,用于内部 Wearesho Team 项目使用
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
- dev-master
- 1.16.6
- 1.16.5
- 1.16.4
- 1.16.3
- 1.16.2
- 1.16.1
- 1.16
- 1.15.1
- 1.15.0
- 1.14.1
- 1.14.0
- 1.13
- 1.12.0
- 1.11
- 1.10.0
- 1.9.0
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.0
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.7
- 1.3.6
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3
- 1.2.1
- 1.2
- 1.1.1
- 1.1
- 1.0.0
- 1.0.0-beta2
- 1.0.0-beta
- dev-dependabot/composer/yiisoft/yii2-2.0.50
- dev-feature/travis-cache
- dev-feature/cghooks
- dev-feature/extend-tests
- dev-tests/controller
- dev-feature/access-control
This package is auto-updated.
Last update: 2024-09-03 21:01:36 UTC
README
HTTP 的替代工作
内容
查看
实现您的视图
<?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, ]; } }
然后使用它
<?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 [示例]
从 \yii\web\Request::get() 中填充面板属性。
安装
composer require wearesho-team/yii-http
添加到您的 DI 容器中
<?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);
待办事项
- 文档
- 测试
许可协议
MIT