php - 建立第一个 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();
?>
解决方案
问题在于加载 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 用于新项目。
推荐阅读
- excel - Excel 中的唯一文本值
- python - 如何使用 tkinter 创建下一个按钮以在多个帧之间切换
- python - 如何专门自动抓取维基百科信息框并使用 python 为任何维基页面打印数据?
- c# - 如何在 ASP.NET MVC 中的控制器方法完成之前显示加载器图像?
- android - 如何将视频标题传递到视频播放器
- python - 在不使用正则表达式的情况下删除字符串中的标点符号和空格
- xaml - 我们可以在 app.xaml 以外的其他地方为 xamarin 表单控件模板定义资源吗
- c# - C#在没有管理员权限的情况下创建用户ODBC
- c# - 如何在excel中将纹理填充类型设置为“堆栈”?
- reactjs - 收音机,无法读取 null 的属性“focusVisible”