我正在尝试在编写 localhost 时打开我的第一个 yii 应用程序,但出现此错误:
警告: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') 在 C:\inetpub\wwwroot\index.php 第 13 行
我必须把 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();
?>
问题在于加载 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';
The dirname(__FILE__)
is the dirname
(parent directory path) of your 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 用于新项目。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句