Yii2 ReflectionException类cebe \ markdown \ Markdown不存在

时间:2017-03-07 18:29:24

标签: yii

我尝试用Mark Safronov,Jeffrey Winesett的Yii 2和PHP从Web应用程序开发中提取样本。

我在页面http://mysite.local/site/docs

时遇到错误
ReflectionException
Class cebe\markdown\Markdown does not exist
    1. in C:\Server\domains\crmapp\vendor\yiisoft\yii2\di\Container.php

但文件vendor \ cebe \ markdown \ Markdown.php存在。

请你帮我解决这个问题。

我的config \ web.php是

<?php
return [
    'id' => 'crmapp',
    'basePath' => realpath (__DIR__ . '/../'),
    'components' => [
        'request' => [
            'cookieValidationKey' => 'wtRTWE4RW#4&Fdsa@',
        ],
        'db' => require(__DIR__ . '/db.php'),
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
        ],
        'view' => [
            'renderers' => [
                'md' => [
                    'class' => 'app\utilities\MarkdownRenderer'
                ]
            ],
        ],
    ],
    'extensions' => require(__DIR__ . '/../vendor/yiisoft/extensions.php')  
];

utilities \ MarkdownRenderer.php是

<?php
namespace app\utilities;
use yii\helpers\Markdown;
use yii\base\ViewRenderer;
class MarkdownRenderer extends ViewRenderer
{
    public function render($view, $file, $params)
    {
        return Markdown::process(file_get_contents($file));
    }
}

控制器\ SiteController.php

<?php
namespace app\controllers;
use \yii\web\Controller;

class SiteController extends Controller
{
    public function actionIndex()
    {
        return 'Our CRM';
    }

    public function actionDocs()
{
    return $this->render('docindex.md');
    }
}

vendor \ yiisoft \ yii2 \ composer.json是

{
"name": "yiisoft/yii2",
"description": "Yii PHP Framework Version 2",
"keywords": [
    "yii2",
    "framework"
],
"homepage": "http://www.yiiframework.com/",
"type": "library",
"license": "BSD-3-Clause",
"authors": [
    {
        "name": "Qiang Xue",
        "email": "qiang.xue@gmail.com",
        "homepage": "http://www.yiiframework.com/",
        "role": "Founder and project lead"
    },
    {
        "name": "Alexander Makarov",
        "email": "sam@rmcreative.ru",
        "homepage": "http://rmcreative.ru/",
        "role": "Core framework development"
    },
    {
        "name": "Maurizio Domba",
        "homepage": "http://mdomba.info/",
        "role": "Core framework development"
    },
    {
        "name": "Carsten Brandt",
        "email": "mail@cebe.cc",
        "homepage": "http://cebe.cc/",
        "role": "Core framework development"
    },
    {
        "name": "Timur Ruziev",
        "email": "resurtm@gmail.com",
        "homepage": "http://resurtm.com/",
        "role": "Core framework development"
    },
    {
        "name": "Paul Klimov",
        "email": "klimov.paul@gmail.com",
        "role": "Core framework development"
    },
    {
        "name": "Dmitry Naumenko",
        "email": "d.naumenko.a@gmail.com",
        "role": "Core framework development"
    },
    {
        "name": "Boudewijn Vahrmeijer",
        "email": "info@dynasource.eu",
        "homepage": "http://dynasource.eu",
        "role": "Core framework development"
    }
],
"support": {
    "issues": "https://github.com/yiisoft/yii2/issues?state=open",
    "forum": "http://www.yiiframework.com/forum/",
    "wiki": "http://www.yiiframework.com/wiki/",
    "irc": "irc://irc.freenode.net/yii",
    "source": "https://github.com/yiisoft/yii2"
},
"require": {
    "php": ">=5.4.0",
    "ext-mbstring": "*",
    "ext-ctype": "*",
    "lib-pcre": "*",
    "yiisoft/yii2-composer": "~2.0.4",
    "ezyang/htmlpurifier": "~4.6",
    "cebe/markdown": "~1.0.0 | ~1.1.0",
    "bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable",
    "bower-asset/jquery.inputmask": "~3.2.2 | ~3.3.3",
    "bower-asset/punycode": "1.3.*",
    "bower-asset/yii2-pjax": "~2.0.1"
},
"autoload": {
    "psr-4": {"yii\\": ""}
},
"bin": [
    "yii"
],
"extra": {
    "branch-alias": {
        "dev-master": "2.0.x-dev"
    }
}
}

1 个答案:

答案 0 :(得分:0)

我添加到utilities \ MarkdownRenderer.php是

require_once __DIR__ . '/../vendor/autoload.php';

问题解决了