Where should I place my app's yiic file to execute console commands?

时光总嘲笑我的痴心妄想 提交于 2020-01-25 00:15:53

问题


When you generate Yii 1.x auto-generated application, app's private yiic is placed in protected folder. However, when I use it to execute yiic help shell, I see following message:

It is recommended that you execute this command under
the directory that contains the entry script file of
the Web application.

And then:

* 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.

What am I missing? The protected folder is not the same folder as entry script's one (index.php). Should I move my yiic there for the purpose of executing console commands?

If yes, then why yiic is placed protected folder by default, not there, where entry script is?

If not, then why yiic assumes, that index.php exists in the same folder as yiic itself and why do I have to change this every time with using entry-script flag? This just doesn't make any sense!

I think, the answer is to keep yiic in protected folder, which is secured from web access by .htaccess file. Entry script's folder is not secured that way and is web accessible. I would personally be very worried about moving yiic to root folder, where index.php file exists. If this is the correct answer, then what is the purpose of this confusing message, cited above?

This answer seems to be supporting my idea, as it shows that CRON call should point to yiic placed in protected folder, not to the one in root folder.

Why Yii developers put yiic, where it is not supposed to be (it is looking for index.php in the same folder, so in default auto-generated application, it will fail, not finding it)? How should I understand this situation? Why I'm forced to use extra flag every time? Why default folder structure and file placement does not replicate, what yiic assumes as default?


回答1:


What the help message means is that you should execute the yiic command from the WebRoot folder (where your index.php is) like so:

% cd WebRoot
% YiiRoot/framework/yiic shell

So yii will take automatically your index.php file to do its things... But if you want to call another file like index-test.php to get yii executed instead of the default index.php you can:

% cd WebRoot
% YiiRoot/framework/yiic shell index-test.php

http://www.yiiframework.com/doc/guide/1.1/en/topics.console



来源:https://stackoverflow.com/questions/24570233/where-should-i-place-my-apps-yiic-file-to-execute-console-commands

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!