problems running custom command in yiic shell

I already asked this is the appropriate forum related to


Agile Web Application Development with Yii 1.1 and PHP5

but not getting any leads there so trying here.

I am trying to run the Yiic shell to execute a custom rbac command that propagates a user access scheme in the TrackStar application in the book.

However I cannot load the Yiic shell.

If i go to my project directory and excecute:


users-MacBook-Air:trackstar user$ protected/yiic shell

I get output like this instead of a shell launch.





....

<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;}


....and so on...



If I go directly to the yiic tool:


protect/yiic shell

I get output like this:


users-MacBook-Air:protected user$ ./yiic shell

Error: index.php does not exist or is not an entry script file.


USAGE

  yiic shell [entry-script | config-file]


DESCRIPTION

  This command allows you to interact with a Web application

  on the command line. It also provides tools to automatically

  generate new controllers, views and data models.


  It is recommended that you execute this command under

  the directory that contains the entry script file of

  the Web application.


PARAMETERS

 * entry-script | config-file: optional, the path to

   the entry script file or the configuration file for

   the Web application. If not given, it is assumed to be

   the 'index.php' file under the current directory.



And am returned to my prompt.

If I do something like


 ./yiic shell ../index.php

I once more get the html output.

I am using Yii 1.1.2 (the version the book uses) with the latest MAMP and OS X 1.7.2

Any help would be great appreciated!

thanks

update: I have captured the shell output and it is as follow:


PHP Error


Description


date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead


Source File


/Users/user/Dropbox/localhost/trackstar/protected/views/layouts/main.php(47)


00035:                 array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest)

00036:             ),

00037:         )); ?>

00038:     </div><!-- mainmenu -->

00039: 

00040:     <?php $this->widget('zii.widgets.CBreadcrumbs', array(

00041:         'links'=>$this->breadcrumbs,

00042:     )); ?><!-- breadcrumbs -->

00043: 

00044:     <?php echo $content; ?>

00045: 

00046:     <div id="footer">

00047:         Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/>

00048:         All Rights Reserved.<br/>

00049:         <?php echo Yii::powered(); ?>

00050:     </div><!-- footer -->

00051: 

00052: </div><!-- page -->

00053: 

00054: </body>

00055: </html>

Stack Trace


#0 /Users/user/Dropbox/localhost/trackstar/protected/views/layouts/main.php(47): date()

#1 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require()

#2 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): SiteController->renderInternal()

#3 /Users/user/Dropbox/localhost/yii/framework/web/widgets/CContentDecorator.php(78): SiteController->renderFile()

#4 /Users/user/Dropbox/localhost/yii/framework/web/widgets/CContentDecorator.php(56): CContentDecorator->decorate()

#5 /Users/user/Dropbox/localhost/yii/framework/web/widgets/COutputProcessor.php(45): CContentDecorator->processOutput()

#6 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(207): CContentDecorator->run()

#7 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(302): SiteController->endWidget()

#8 /Users/user/Dropbox/localhost/trackstar/protected/views/layouts/column1.php(7): SiteController->endContent()

#9 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119): require()

#10 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88): SiteController->renderInternal()

#11 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(689): SiteController->renderFile()

#12 /Users/user/Dropbox/localhost/trackstar/protected/controllers/SiteController.php(32): SiteController->render()

#13 /Users/user/Dropbox/localhost/yii/framework/web/actions/CInlineAction.php(32): SiteController->actionIndex()

#14 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(300): CInlineAction->run()

#15 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(278): SiteController->runAction()

#16 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(257): SiteController->runActionWithFilters()

#17 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(320): SiteController->run()

#18 /Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(120): CWebApplication->runController()

#19 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135): CWebApplication->processRequest()

#20 /Users/user/Dropbox/localhost/trackstar/index.php(12): CWebApplication->run()

#21 /Users/user/Dropbox/localhost/yii/framework/cli/commands/ShellCommand.php(78): require()

#22 /Users/user/Dropbox/localhost/yii/framework/console/CConsoleCommandRunner.php(62): ShellCommand->run()

#23 /Users/user/Dropbox/localhost/yii/framework/console/CConsoleApplication.php(88): CConsoleCommandRunner->run()

#24 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135): CConsoleApplication->processRequest()

#25 /Users/user/Dropbox/localhost/yii/framework/yiic.php(33): CConsoleApplication->run()

#26 /Users/user/Dropbox/localhost/trackstar/protected/yiic.php(7): require_once()

#27 /Users/user/Dropbox/localhost/trackstar/protected/yiic(4): require_once()

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/exception.php on line 71 2011-10-22 15:07:52 Yii Framework/1.1.2

Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27 Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead in /Users/user/Dropbox/localhost/yii/framework/views/log.php on line 27

Application Log

Timestamp	Level	Category	Message

15:07:52.612484	trace	system.CModule	

Loading "log" application component

15:07:52.615725	trace	system.CModule	

Loading "request" application component

15:07:52.632834	trace	system.CModule	

Loading "urlManager" application component

15:07:52.683854	trace	system.CModule	

Loading "user" application component

15:07:52.686465	trace	system.CModule	

Loading "session" application component

15:07:52.704266	error	php	

date(): It is not safe to rely on the system's timezone settings. You are

*required* to use the date.timezone setting or the

date_default_timezone_set() function. In case you used any of those methods

and you are still getting this warning, you most likely misspelled the

timezone identifier. We selected 'Europe/Paris' for 'WEST/1.0/DST' instead

(/Users/user/Dropbox/localhost/trackstar/protected/views/layouts/main.php:47)

Stack trace:

#0 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88):

SiteController->renderInternal()

#1

/Users/user/Dropbox/localhost/yii/framework/web/widgets/CContentDecorator.php(78):

SiteController->renderFile()

#2

/Users/user/Dropbox/localhost/yii/framework/web/widgets/CContentDecorator.php(56):

CContentDecorator->decorate()

#3

/Users/user/Dropbox/localhost/yii/framework/web/widgets/COutputProcessor.php(45):

CContentDecorator->processOutput()

#4

/Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(207):

CContentDecorator->run()

#5

/Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(302):

SiteController->endWidget()

#6

/Users/user/Dropbox/localhost/trackstar/protected/views/layouts/column1.php(7):

SiteController->endContent()

#7

/Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(119):

require()

#8 /Users/user/Dropbox/localhost/yii/framework/web/CBaseController.php(88):

SiteController->renderInternal()

#9 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(689):

SiteController->renderFile()

#10

/Users/user/Dropbox/localhost/trackstar/protected/controllers/SiteController.php(32):

SiteController->render()

#11

/Users/user/Dropbox/localhost/yii/framework/web/actions/CInlineAction.php(32):

SiteController->actionIndex()

#12 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(300):

CInlineAction->run()

#13 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(278):

SiteController->runAction()

#14 /Users/user/Dropbox/localhost/yii/framework/web/CController.php(257):

SiteController->runActionWithFilters()

#15

/Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(320):

SiteController->run()

#16

/Users/user/Dropbox/localhost/yii/framework/web/CWebApplication.php(120):

CWebApplication->runController()

#17 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135):

CWebApplication->processRequest()

#18 /Users/user/Dropbox/localhost/trackstar/index.php(12):

CWebApplication->run()

#19

/Users/user/Dropbox/localhost/yii/framework/cli/commands/ShellCommand.php(78):

require()

#20

/Users/user/Dropbox/localhost/yii/framework/console/CConsoleCommandRunner.php(62):

ShellCommand->run()

#21

/Users/user/Dropbox/localhost/yii/framework/console/CConsoleApplication.php(88):

CConsoleCommandRunner->run()

#22 /Users/user/Dropbox/localhost/yii/framework/base/CApplication.php(135):

CConsoleApplication->processRequest()

#23 /Users/user/Dropbox/localhost/yii/framework/yiic.php(33):

CConsoleApplication->run()

#24 /Users/user/Dropbox/localhost/trackstar/protected/yiic.php(7):

require_once()

#25 /Users/user/Dropbox/localhost/trackstar/protected/yiic(4):

require_once()

REQUEST_URI=/index.php

15:07:52.704550	trace	system.CModule	

Loading "errorHandler" application component

I tried commenting out that particular data() call on line 46 but I got another error in the framework.

How do I change my server settings to give Yii what it wants or change my app to get the correct timezone.

update:

I seem to have fixed this by changing the code to:


<div id="footer">

		<?php date_default_timezone_set("Europe/Lisbon"); ?>

		Copyright &copy; <?php echo date('Y'); ?> by My Company.<br/>

		All Rights Reserved.<br/>

		<?php echo Yii::powered(); ?>

	</div><!-- footer -->

But I would still like to know why this is happening or if this a Yii/MAMP bug of some sort.

try ./yiic shell /path/to/config/file.php

Same to me. Everything and output from terminal is just like that.

I think an important info about how to add yiic command to OS X or Terminal is missing. Could you provide it or guide us to the resource? It is a little bit disappoint after choose a framework, bought a book, and found there is no content to setup yiic to work on OS X system.

I just found the way to make it work. Thanks sensorario for his guideline.

For example, if I am at the project root folder "demo". I have to run this command in terminal:




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



Hope it can help others.

Thank you, it helped me!

If you look at the php.ini file and look for the date setting, you will find the following:

[Date]

; Defines the default timezone used by the date functions

; Will be changed by MAMP to system timezone

date.timezone = "Australia/Melbourne"

Note the comment that states that MAMP will change the timezone back to the system settings.

Thankyou, that helped me as well.

Strangely, it works perfectly fine from my personal laptop without this method where same version of EasyPHP and Yii framework is installed. Where as it doesn’t work from my Org laptop

Thanks Macdemac. Could you please elaborate. What needs to be done to fix this issue of Yiic Shell not working without path and HTML output along with Datetime warning is displayed.

Thanks to all, on my windows PC I had to give the complete path to make it work… something like this.


php demo\protected>>yiic shell C:\demo\protected\config\main.php

Thank you very much, it helps me >w<

i’m also following book but was stuck there,

not to mention yii 1.1.2 doesn’t have gii,

so i have no choice but to find the answer for this problem, my gawd~ (clueless about cmd)

what works for me :




C:\Windows\System32>cd c:/xampp/htdocs/demo


c:\xampp\htdocs\demo>php protected/yiic shell protected/config/main.php


Yii Interactive Tool v1.1 (based on Yii v1.1.2)

Please type 'help' for help. Type 'exit' to quit.

>> help

At the prompt, you may enter a PHP statement or one of the following commands:

 - controller

 - crud

 - form

 - help

 - model

 - module


Type 'help <command-name>' for details about a command.


To expand the above command list, place your command class files

under 'protected/commands/shell', or a directory specified

by the 'YIIC_SHELL_COMMAND_PATH' environment variable. The command class

must extend from CConsoleCommand.