yiic 命令行工具输出代码而不是打开 shell

发布于 2024-12-11 05:43:26 字数 1221 浏览 0 评论 0原文

当我运行命令: users-MacBook-Air:trackstar user$ ../yii/framework/yiic shell

应该启动 Yii 的 yiic shell 工具。我只是得到这样的输出:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
PHP Error</title>

<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-size:9pt;}
pre {font-family:"Lucida Console";font-size:10pt;}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
.message {color: maroon;}
.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;}
.error {background-color: #ffeeee;}
/*]]>*/
</style>
</head>

<body>

等等,知道为什么会发生这种情况吗?

When I run the command: users-MacBook-Air:trackstar user$ ../yii/framework/yiic shell

Which should launch the yiic shell tool for Yii. I instead just get output like this:

<!DOCTYPE html PUBLIC
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>
PHP Error</title>

<style type="text/css">
/*<![CDATA[*/
body {font-family:"Verdana";font-weight:normal;color:black;background-color:white;}
h1 { font-family:"Verdana";font-weight:normal;font-size:18pt;color:red }
h2 { font-family:"Verdana";font-weight:normal;font-size:14pt;color:maroon }
h3 {font-family:"Verdana";font-weight:bold;font-size:11pt}
p {font-family:"Verdana";font-size:9pt;}
pre {font-family:"Lucida Console";font-size:10pt;}
.version {color: gray;font-size:8pt;border-top:1px solid #aaaaaa;}
.message {color: maroon;}
.source {font-family:"Lucida Console";font-weight:normal;background-color:#ffffee;}
.error {background-color: #ffeeee;}
/*]]>*/
</style>
</head>

<body>

And so on, any idea why this is happening?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

权谋诡计 2024-12-18 05:43:26

试试这个

./protected/yiic shell protected/config/main.php

Try this instead

./protected/yiic shell protected/config/main.php
深爱不及久伴 2024-12-18 05:43:26

这是我遇到的问题(因为我似乎在同一本书上并且也在 Mac 上),我使用的是 XAMPP,但我尝试了 MAMP 并遇到了同样的问题。

One:尝试运行 yiic shell 时的 HTML 输出
解决方案:这与 yiic shell 必须确保您的 php.ini 时区设置正确有关,不幸的是,像 MAMP 甚至 XAMPP 这样的系统都有想要根据系统设置强制执行时区的习惯,这并不始终与 PHP 提供的 date.timezone 函数匹配,为了解决此问题,请将以下内容添加到 main.php 文件的顶部

// Fix for server incompatibilities
date_default_timezone_set('UTC');

:尝试运行 Yii::app()->db->connectionString 时找不到文件问题;
解决方案:出于某种原因,yii 和 PHP 想要在不存在的地方查找 mysql.sock,您必须强制它在需要查找的地方查找。另外,有时“localhost”无法正常工作,因此您应该使用您的“家庭”IP,最常见的是 127.0.0.1(即使在网络上,除非您手动设置了它)。这将使您的连接字符串如下所示。

'connectionString' => 'mysql:host=127.0.0.1;dbname=DBNAME;unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',

您的 mysql.sock 可能位于不同的位置,请检查 phpinfo();页面来找出答案。 (这可以适用于 MAMP 和 XAMPP)

:用户 * 在 * 上的访问被拒绝,这是其中最愚蠢的一个,因为我在 MySQL 中设置了我的用户,我将用户设置为接受所有输入位置(又名 %),似乎访问被拒绝在 MAMP 和 XAMPP 上都是不可避免的,这是我唯一的解决方案,删除 % 访问权限(甚至可能删除您的用户),并确保它们仅设置为“本地” “ 或者“本地主机”。然后就可以连接了。

我花了两天时间才解决所有这些问题,现在我开始在 Mac 上使用 xampp 安装 pear...耶。

So here's the issues I ran into (since I seem to be on the same book and on a Mac as well), I'm using XAMPP but I tried MAMP and had the same issue.

One: HTML Output when trying to run yiic shell
Resolution: This has to do with the yiic shell having to make sure your php.ini time zone is set right, unfortunately, systems like MAMP and even XAMPP have a habit of wanting to enforce your time zone based on system settings, this does not always match up to the date.timezone function PHP offers, in order to resolve this, add the following to the top of the main.php file below the

// Fix for server incompatibilities
date_default_timezone_set('UTC');

Two: Can not find file issue when attempting to run Yii::app()->db->connectionString;
Resolution: For some reason yii and PHP want to look for the mysql.sock in places it is not, you have to enforce it to look where it needs to look. Also, sometimes "localhost" doesn't work properly, so you should use your "home" IP, most commonly 127.0.0.1 (even if on a network, unless you've manually set it otherwise). This will make your connection string look something like the following.

'connectionString' => 'mysql:host=127.0.0.1;dbname=DBNAME;unix_socket=/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock',

Your mysql.sock may be in a different location, check a phpinfo(); page to find out. (This can apply to MAMP and XAMPP)

Three: Access denied for user * on *, this one is the most silly of them all, as I set up my user in MySQL I set the user to accept all input locations (a.k.a. %), it seems access denied is an inevitability on both MAMP and XAMPP with this, the only resolution I had, remove % access (possibly even remove your user), and make sure they are only set to "local" or "localhost". It will then be able to connect.

It took me two days to get all this sorted out, now I get to move onto getting pear installed with xampp on a Mac... yay.

爱的十字路口 2024-12-18 05:43:26

从标题标签来看,它看起来像是一个 PHP 错误。 yiic 工具是一个 PHP 脚本。如果错误消息不在输出本身中,您是否检查过 PHP 错误日志?

From the title tag it looks like a PHP error. The yiic tool is a PHP script. If the error message isn't in the output itself, did you check your PHP error log?

柠檬心 2024-12-18 05:43:26

有类似的问题。我的问题是由 main.php 中的 urlManager 组件引起的。恢复到过去的工作代码对我来说是排序的。不幸的是,这意味着每次我需要运行 yiic shell 时都将 main.php 恢复回来。

Had a similar problem. Mine was caused in urlManager component inside main.php. Reverting back to past working code sorted it for me. Unfortunately this means reverting main.php back every time I need to run yiic shell.

缺⑴份安定 2024-12-18 05:43:26

我有一段时间遇到了同样的问题:HTML 列表而不是控制台 yiic 运行。

最后我在 config/main.php 的“预加载”部分发现了一个错误:配置引用了一个丢失的组件。

所以我的建议是仔细浏览 yicc 生成的 HTML 列表并查找任何错误和/或尝试更正/验证 main.php 配置

I experienced for a while the same problem: HTML listing instead of console yiic running.

In the end I discovered an error in the "preload" section of config/main.php: a configuration referenced a component that was missing.

So my suggestion is to carefully browse the HTML listing produced by yicc and look for any errors and/or try to correct/verify the main.php configuration

指尖凝香 2024-12-18 05:43:26

对于 Mac 用户,请查看此内容。 。 。

Mac:testdrive user$ ./protected/yiic shell protected/config/main.php

这对我有用。 。 。

For Mac User, check this out . . .

Mac:testdrive user$ ./protected/yiic shell protected/config/main.php

this worked for me . . .

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文