简体   繁体   中英

yiic command line tool outputting code instead of opening shell

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?

试试这个

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

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 (aka %), 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.

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.

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

For Mac User, check this out . . .

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

this worked for me . . .

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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM