首页 > 解决方案 > 建立第一个 yii 项目

问题描述

我试图打开我的第一个 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:\第 13 行 C:\inetpub\wwwroot\index.php 中的 php\pear')

我必须把 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();
?>

标签: phpyii

解决方案


问题在于加载 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__)是你的dirname(父目录路径)index.php,所以你不应该附加一个绝对路径,而是一个相对路径,例如:

$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 用于新项目。


推荐阅读