我正在YII2
创建apis,每个请求都运行良好,但在PUT
请求中我遇到错误
未知属性 - yii \ base \ UnknownPropertyException
设置未知属性:yii \ filters \ auth \ HttpBearerAuth :: formats
这是我的堆栈跟踪
在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Object.php第161行152153154155156157158159160161162163164165166167168169170
* / public function __set($ name,$ value) { $ setter =' set' 。 $名称; if(method_exists($ this,$ setter)){ $这 - > $设定器($值); } elseif(method_exists($ this,' get'。$ name)){ 抛出新的InvalidCallException('设置只读属性:' .get_class($ this)。' ::'。$ name); } else { 抛出新的UnknownPropertyException('设置未知属性:' .get_class($ this)。' ::'。$ name); } }/ **
- 检查属性是否已设置,即已定义且不为空。 *
- 不要直接调用此方法,因为它是一种PHP魔术方法
执行isset($object->property)
时将隐式调用- 。 *
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ BaseYii.php第525行 - yii \ base \ Object :: __ set(' formats',[' application / json' => ' JSON'])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Object.php第105行 - yii \ BaseYii :: configure(yii \ filters \ auth \ HttpBearerAuth, ['仅' => ['索引','查看','创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']])
- yii \ base \ Object :: __ construct([' only' => [' index',' view',' create' ;,'更新',...],'格式' => [' application / json' =>' json'] ])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ di \ Container.php第381行 - ReflectionClass :: newInstanceArgs([[' only' => [&#39 ;索引&#39 ;, '查看','创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']]])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ di \ Container.php第156行 - yii \ di \ Container :: build(' yii \ filters \ auth \ HttpBearerAuth&#39 ;, [],['仅' => ['索引','查看','创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ BaseYii.php第344行 - yii \ di \ Container :: get(' yii \ filters \ auth \ HttpBearerAuth', [], ['仅' => ['索引','查看','创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Component.php第667行 - yii \ BaseYii :: createObject([' class' => ' yii \ filters \ auth \ HttpBearerAuth','仅' => [' index',' view', '创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Component.php第651行 - yii \ base \ Component :: attachBehaviorInternal(0,[' class' => ' yii \ filters \ auth \ HttpBearerAuth','仅' => ['索引','查看','创建','更新',...],'格式' => ['应用/ JSON' => ' JSON']])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Component.php第533行 - yii \ base \ Component :: ensureBehaviors()
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Controller.php第272行 - yii \ base \ Component :: trigger(' beforeAction', YII \基\的ActionEvent)
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ web \ Controller.php第164行 - yii \ base \ Controller :: beforeAction(yii \ rest \ UpdateAction)
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Controller.php第154行 - yii \ web \ Controller :: beforeAction(yii \ rest \ UpdateAction)
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Module.php第523行 - yii \ base \ Controller :: runAction(' update',[&#39] ; id' =>' 1'])
- 在第102行的D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ web \ Application.php中 - yii \ base \ Module :: runAction(' products / update',[& #39; id' => ' 1'])
- 在D:\ xampp \ htdocs \ connect \ vendor \ yiisoft \ yii2 \ base \ Application.php中 第380行 - yii \ web \ Application :: handleRequest(yii \ web \ Request)
- 在D:\ xampp \ htdocs \ connect \ index.php第12行 - yii \ base \ Application :: run()6789101112 require( DIR 。 ' /vendor/autoload.php');要求( DIR 。 ' /vendor/yiisoft/yii2/Yii.php'); $ config = require( DIR 。 ' /config/web.php'); (new yii \ web \ Application($ config)) - > run(); $ _GET = [ ' ID' => ' 1',]; Yii Framework 2017-02-23,09:31:51
醇>Apache / 2.4.23(Win32)OpenSSL / 1.0.2h PHP / 5.6.28 Yii Framework / 2.0.11.2
控制器中的行为是
public function behaviors() {
return [
[
'class' => HttpBearerAuth::className(),
'only' => ['index', 'view', 'create', 'update', 'search'],
'formats' => ['application/json' => Response::FORMAT_JSON,],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'index' => ['get'],
'view' => ['get'],
'create' => ['post'],
'update' => ['PUT'],
'delete' => ['delete'],
'deleteall' => ['post'],
'search' => ['get']
],
]
];
}
我正在使用postman
对其进行测试,并在每个api中传递Authorization
。
这是我的标题
可能是什么问题?