我安装了Netbenas、XAMPP、xdebug和Yii2,还有简单的REST控制器:
<?php
namespace app\controllers;
use yii\rest\ActiveController;
class ContractController extends ActiveController
{
public $modelClass = 'app\models\Contract';
}它连接到FireBird2.1数据库(WIN1257)并给出错误:
error on line 2 at column 431: Encoding error我想调试这个错误,以确定如何改进Yii插件,但是如果这个控制器没有动作(使用基类的操作),我可以在哪里放置断点。在运行拥挤状态中,我有Project:
http://localhost:8081/myproject/和索引文件:
web/index.php我的意图是在这里放置错误的网址:
http://localhost:8081/myproject/web/index.php/contract但是Netbeans不接受索引文件字段中的/contract部件。
那么,我应该在Netbenas中打开哪个文件,以及如何指示我要调试url http://localhost:8081/myproject/web/index.php/contract。
发布于 2016-08-14 07:28:29
你的
class ContractController extends ActiveController是ActiveController的扩展
这样您就可以将断点放置到适当的ActiveController操作上。
在……里面
vendor/yiisoft/yii2/rest/ActionController 你可以找到
public function actions()
{
return [
'index' => [
'class' => 'yii\rest\IndexAction',
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
],
'view' => [
'class' => 'yii\rest\ViewAction',
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
],
'create' => [
'class' => 'yii\rest\CreateAction',
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
'scenario' => $this->createScenario,
],
'update' => [
'class' => 'yii\rest\UpdateAction',
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
'scenario' => $this->updateScenario,
],
'delete' => [
'class' => 'yii\rest\DeleteAction',
'modelClass' => $this->modelClass,
'checkAccess' => [$this, 'checkAccess'],
],
'options' => [
'class' => 'yii\rest\OptionsAction',
],
];
}在这里你可以看到,对于每一个动作,你都有一个适当的类,例如:。
'class' => 'yii\rest\IndexAction',在同一个dir vendor/yiisoft/yii2/rest/ActionController中,可以找到类代码。
然后,您可以将断点放在相关的类run函数上。
public function run()
{
if ($this->checkAccess) {
call_user_func($this->checkAccess, $this->id);
}
return $this->prepareDataProvider();
}https://stackoverflow.com/questions/38932534
复制相似问题