带消息的yii \ base \ InvalidParamException视图文件不存在

时间:2016-04-14 08:26:30

标签: php yii2

我对Yii框架很新 设置提前Yii 时,我只做了基本的必修步骤。但是当我尝试在前端加载index.php(localhost:8888 / new / advanced / frontend / web / index.php)以及index.php(localhost:8888 / new)时,它会出现以下错误/advanced/backend/web/index.php)在后端。

我从一开始就做的事情:

  1. 下载了高级Yii框架&将其提取到htdocs
  2. 在终端中运行命令php init
    所有......
  3. 我尝试了这个解决方案yii2-error-the-view-file-does-not-exist ..但它没有效果

    错误

    An Error occurred while handling another error:
    exception 'yii\base\InvalidParamException' with message 'The view file does not exist: /Applications/MAMP/htdocs/SMS_Messenger/vendor/yiisoft/yii2/views/errorHandler/exception.php' in /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/View.php:226
    Stack trace:
    #0 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/ErrorHandler.php(241): yii\base\View->renderFile('@yii/views/erro...', Array, Object(yii\web\ErrorHandler))
    #1 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/ErrorHandler.php(112): yii\web\ErrorHandler->renderFile('@yii/views/erro...', Array)
    #2 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/ErrorHandler.php(109): yii\web\ErrorHandler->renderException(Object(yii\base\InvalidParamException))
    #3 [internal function]: yii\base\ErrorHandler->handleException(Object(yii\base\InvalidParamException))
    #4 {main}
    Previous exception:
    exception 'yii\base\InvalidParamException' with message 'The file or directory to be published does not exist: /Applications/MAMP/htdocs/SMS_Messenger/vendor/yiisoft/yii2/assets' in /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/AssetManager.php:452
    Stack trace:
    #0 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/AssetBundle.php(179): yii\web\AssetManager->publish('/Applications/M...', Array)
    #1 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/AssetManager.php(266): yii\web\AssetBundle->publish(Object(yii\web\AssetManager))
    #2 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/AssetManager.php(237): yii\web\AssetManager->loadBundle('yii\\web\\YiiAsse...', Array, true)
    #3 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/View.php(284): yii\web\AssetManager->getBundle('yii\\web\\YiiAsse...')
    #4 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/View.php(289): yii\web\View->registerAssetBundle('yii\\web\\YiiAsse...', NULL)
    #5 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/AssetBundle.php(123): yii\web\View->registerAssetBundle('frontend\\assets...')
    #6 /Applications/MAMP/htdocs/new/advanced/frontend/views/layouts/main.php(13): yii\web\AssetBundle::register(Object(yii\web\View))
    #7 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/View.php(325): require('/Applications/M...')
    #8 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/View.php(247): yii\base\View->renderPhpFile('/Applications/M...', Array)
    #9 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/Controller.php(392): yii\base\View->renderFile('/Applications/M...', Array, Object(frontend\controllers\SiteController))
    #10 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/Controller.php(378): yii\base\Controller->renderContent('<div class="sit...')
    #11 /Applications/MAMP/htdocs/new/advanced/frontend/controllers/SiteController.php(75): yii\base\Controller->render('index')
    #12 [internal function]: frontend\controllers\SiteController->actionIndex()
    #13 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/InlineAction.php(55): call_user_func_array(Array, Array)
    #14 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/Controller.php(154): yii\base\InlineAction->runWithParams(Array)
    #15 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/Module.php(454): yii\base\Controller->runAction('', Array)
    #16 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('', Array)
    #17 /Applications/MAMP/htdocs/new/advanced/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
    #18 /Applications/MAMP/htdocs/new/advanced/frontend/web/index.php(18): yii\base\Application->run()
    #19 {main} 
    

    前端sitecontroller.php

    <?php
    namespace frontend\controllers;
    
    use Yii;
    use common\models\LoginForm;
    use frontend\models\PasswordResetRequestForm;
    use frontend\models\ResetPasswordForm;
    use frontend\models\SignupForm;
    use frontend\models\ContactForm;
    use yii\base\InvalidParamException;
    use yii\web\BadRequestHttpException;
    use yii\web\Controller;
    use yii\filters\VerbFilter;
    use yii\filters\AccessControl;
    class SiteController extends Controller
    {
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'only' => ['logout', 'signup'],
                'rules' => [
                    [
                        'actions' => ['signup'],
                        'allow' => true,
                        'roles' => ['?'],
                    ],
                    [
                        'actions' => ['logout'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                ],
            ],
            'verbs' => [
                'class' => VerbFilter::className(),
                'actions' => [
                    'logout' => ['post'],
                ],
            ],
        ];
    }
    
    /**
     * @inheritdoc
     */
    public function actions()
    {
        return [
            'error' => [
                'class' => 'yii\web\ErrorAction',
            ],
            'captcha' => [
                'class' => 'yii\captcha\CaptchaAction',
                'fixedVerifyCode' => YII_ENV_TEST ? 'testme' : null,
            ],
        ];
    }
    
    /**
     * Displays homepage.
     *
     * @return mixed
     */
    public function actionIndex()
    {
        return $this->render('index');
    }
    
    //other codes
    

    我的环境是Mac OS 10.11 El capitain
    因为我是Yii&amp; amp;的新手我没有改变默认代码,很难找出问题 希望有任何建议

1 个答案:

答案 0 :(得分:0)

您没有供应商目录。 从命令行运行composer。可能你必须先安装作曲家。然后在高级项目运行的根目录中:

composer install

php composer install