2016-01-18 22:42:50 2247次浏览 0条回答 0 悬赏 88 金钱

说反射类没找着吗?这个问题怎么解决
解决了,错误已经指出问题了,还是自己太菜= =

ReflectionException
Class require does not exist

    1. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\di\Container.php at line 415
    

         * @return array the dependencies of the specified class.
         */
        protected function getDependencies($class)
        {
            if (isset($this->_reflections[$class])) {
                return [$this->_reflections[$class], $this->_dependencies[$class]];
            }
     
            $dependencies = [];
            $reflection = new ReflectionClass($class); //运行到这行出错了
     
            $constructor = $reflection->getConstructor();
            if ($constructor !== null) {
                foreach ($constructor->getParameters() as $param) {
                    if ($param->isDefaultValueAvailable()) {
                        $dependencies[] = $param->getDefaultValue();
                    } else {
                        $c = $param->getClass();
                        $dependencies[] = Instance::of($c === null ? null : $c->getName());

    2. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\di\Container.php at line 415 – ReflectionClass::__construct('require')
    3. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\di\Container.php at line 358 – yii\di\Container::getDependencies('require')
    4. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\di\Container.php at line 151 – yii\di\Container::build('require', [], ['attributes' => ['id', 'title', 'content', 'tags']])
    5. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\BaseYii.php at line 344 – yii\di\Container::get('require', [], ['attributes' => ['id', 'title', 'content', 'tags']])
    6. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\validators\Validator.php at line 206 – yii\BaseYii::createObject(['attributes' => ['id', 'title', 'content', 'tags'], 'class' => 'require'])
    7. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\base\Model.php at line 441 – yii\validators\Validator::createValidator('require', frontend\modules\post\models\Post, ['id', 'title', 'content', 'tags'], [])
    8. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\base\Model.php at line 405 – yii\base\Model::createValidators()
    9. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\base\Model.php at line 185 – yii\base\Model::getValidators()
    10. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\base\Model.php at line 747 – yii\base\Model::scenarios()
    11. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\vendor\yiisoft\yii2\base\Model.php at line 691 – yii\base\Model::safeAttributes()
    12. in F:\web\apache\Apache24\htdocs\yii2\myapp-advance\advanced\frontend\modules\post\models\PostArticleForm.php at line 50 – yii\base\Model::setAttributes(['type' => '1', 'title' => '傅盛:硅谷研究火箭中国还在做手机', 'tags' => '手机,硅谷', 'content' => '“在硅谷,我没有看到过一家创业公司还在做手机,大家都已经在研究发...'])
 

        {
            if(!$this->validate()){
                return false;
            }
     
            $post = new Post();
            $post->setAttributes($this->attributes); //运行到这里
            if(!$post->postArticle()){
                return false;
            }
     
            Yii::$app->session->setFlash('info','文章已提交,需通过审核才可发布');
            return true;


    没有找到数据。
您需要登录后才可以回答。登录 | 立即注册
aoyo
总监

aoyo

注册时间:2015-09-24
最后登录:2016-04-17
在线时长:31小时2分
  • 粉丝2
  • 金钱2402
  • 威望0
  • 积分2712

热门问题