Issue
When i am trying to run my photoResizer command like this /var/www/myProject/proted/yiic photoResizer
i am getting this error.
PHP Error[8]: Undefined index: SERVER_NAME
in file /var/www/myProject/protected/components/UploadHandler.php at line 190
#0 /var/www/myProject/protected/components/UploadHandler.php(45):
UploadHandler->get_full_url()
#1 /var/www/myProject/protected/commands/PhotoResizerCommand.php(37):
UploadHandler->__construct()
#2 /var/www/myProject/framework/console/CConsoleCommandRunner.php(71):
PhotoResizerCommand->run()
#3 /var/www/myProject/framework/console/CConsoleApplication.php(92):
CConsoleCommandRunner->run()
#4 /var/www/myProject/framework/base/CApplication.php(180):
CConsoleApplication->processRequest()
#5 /var/www/myProject/framework/yiic.php(33): CConsoleApplication->run()
#6 /var/www/myProject/protected/yiic.php(7): require_once()
#7 /var/www/myProject/protected/yiic(4): require_once()
I need to solve this problem or any alternative to run a php script via command line in yii framework.
Thanks.
Solution
Quite obviously there's no "server" when running an app from the command line, so you cannot use that variable for anything. Apparently UploadHandler
is hard coded to expect to be executed in the context of a web request to handle files uploaded within the request (which, you know, makes sense). Since you're not in a web request context, it fails.
Answered By - deceze
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.