【问题标题】:setting up the first yii project建立第一个 yii 项目
【发布时间】:2019-10-30 20:53:39
【问题描述】:

我正在尝试打开我的第一个 yii 应用程序 就在我写 localhost 的时候 它给出了这个错误:

警告:require_once(C:\inetpub\wwwroot/../yii-1.1.21.733ac5/yii-1.1.21.733ac5/framework/yii.php):无法打开流:C 中没有这样的文件或目录:\inetpub\wwwroot\index.php 第 13 行

致命错误:require_once(): 无法打开所需的 'C:\inetpub\wwwroot/../yii-1.1.21.733ac5/yii-1.1.21.733ac5/framework/yii.php' (include_path='.; C:\php\pear') 在第 13 行的 C:\inetpub\wwwroot\index.php 中

yii.app 的文件我必须放在哪个位置?

这是索引中的内容:

<?php

// change the following paths if necessary
$yii=dirname(__FILE__).'C:\yii\yii-1.1.21.733ac5\yii-1.1.21.733ac5\framework\yii.php';

$config=dirname(__FILE__).'/protected/config/main.php';

// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',3);

require_once($yii);
Yii::createWebApplication($config)->run();
?>

【问题讨论】:

    标签: php yii


    【解决方案1】:

    问题在于加载 Yii 框架的路径:

    // change the following paths if necessary
    $yii=dirname(__FILE__).'C:\yii\yii-1.1.21.733ac5\yii-1.1.21.733ac5\framework\yii.php';
    

    dirname(__FILE__) 是您的index.phpdirname(父目录路径),因此您不应附加绝对路径,而应附加相对路径,例如:

    $yii=dirname(__FILE__).'/../yii/framework/yii.php';
    

    或者只使用绝对路径:

    $yii='C:\yii\yii-1.1.21.733ac5\yii-1.1.21.733ac5\framework\yii.php';
    

    您确定文件夹yii-1.1.21.733ac5 应该在路径中出现两次吗?

    最后,请注意 Yii 1 已经到了它的生命周期,并且只接受了安全修复。您绝对应该将 Yii 2 用于新项目。

    【讨论】:

      猜你喜欢
      • 2021-08-05
      • 1970-01-01
      • 2015-07-20
      • 2023-03-29
      • 1970-01-01
      • 2020-12-23
      • 2015-10-17
      • 2021-03-14
      • 2018-04-18
      相关资源
      最近更新 更多