我尝试按照tutorial
扩展 BaseHtml 类但是找不到BaseHtml扩展类
namespace common\components;
class Html extends \yii\helpers\BaseHtml {
}
这是错误:
Class 'yii\helpers\BaseHtml' not found
我哪里错了?
更新
我尝试复制位于Helpers中的Html.php文件并且仍然是相同的
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace yii\helpers;
/**
* Html provides a set of static methods for generating commonly used HTML tags.
*
* Nearly all of the methods in this class allow setting additional html attributes for the html
* tags they generate. You can specify, for example, `class`, `style` or `id` for an html element
* using the `$options` parameter. See the documentation of the [[tag()]] method for more details.
*
* For more details and usage information on Html, see the [guide article on html helpers](guide:helper-html).
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class Html extends BaseHtml
{
}
现在我还有另外一个问题。它找不到原始类的BaseHtml
vendor/yiisoft/yii2/helpers/Html.php
找到解决方案
我重构了覆盖文件,phpStorm改变了我在vendor / yiisoft / yii2 / classe.php中的BaseHtml路径
答案 0 :(得分:0)
BaseHtml.php应位于/ vendor / yiisoft / yii2 / helpers /文件夹下。 如果不存在,您需要更新供应商或尝试将文件BaseHtml.php复制到yii2 / helper yii2 repo:https://github.com/yiisoft/yii2/blob/b7b9c8ba40d65ec7c745ee639a8a6eb96e7aea75/framework/helpers/BaseHtml.php 希望它有所帮助。