我想扩展类yii\web\Response.所以我在文件夹组件中创建了一个新的类Response ,我尝试覆盖send方法.
namespace app\components;
use Yii;
class Response extends \yii\web\Response{
public function init(){
parent::init();
}
/**
* Sends the response to the client.
*/
public function send()
{ ...
Run Code Online (Sandbox Code Playgroud)
最后,我尝试通过在配置中导入它来导入我的新Response-Class.
$config = [
'id' => 'basic',
'basePath' => dirname(__DIR__),
'bootstrap' => ['log'],
'components' => [
'import' => [
'class' => 'app\components\Response',
],
Run Code Online (Sandbox Code Playgroud)
为什么它不会像这样工作?