Closed realtebo closed 8 years ago
You could try doing something like this: https://github.com/yiisoft/yii2/issues/6853
I'm gently requesting a working example. I'm really not able to understand what must I try. You've linked me an issue, so, if it's not working, why moust I try it?
Also, the user is trying to run a console command action inside an other console command or something of similar.
I need to invoke a standard web action from browser and execute the full migration code, up or down.
Please, this situation, a stupid shared host, it's so common. Help us giving us a working example. Please!
About this:https://github.com/yiisoft/yii2/issues/1764#issuecomment-54548817 I'm asking to @stepanselyuk (or to everything else) how to use his helper in a web controller action Sadly, the discussion is closed, so there is no way to contact the user
@realtebo please see https://gist.github.com/stepanselyuk/c7b3ca03755eb5788ce5 - ConsoleAppHelper::runActionOld
this method without using exec
, but as I've figured out, it work only cgi-like modes, ex. fcgid
. But not working with systems where is php as Apache module (don't know why). So I use ConsoleAppHelper::runAction
with exec
.
So you can use helper as:
// for safety
ob_start();
$exitCode = ConsoleAppHelper::runActionOld( 'migrate' );
ob_end_clean();
$output = ConsoleAppHelper::getOutput();
@realtebo it is currently not supported but I linked that issue because there something similar has been tried. By defining the missing constants it may already work but you have to try yourself. We'll look into this when we find the time for it.
when running a console application in web context at least the following things have to be considered:
Yii::$app
.Yii::getLogger()
refers to@app
, and @runtime
alias will be overwritten@vendor
, @bower
, @npm
but these are usually equal.date_default_timezone_set()
will be called if console app has timezone configured.Is it fine to mention https://github.com/samdark/yii2-webshell in the guide? (given that it's not under yiisoft/)
Yes. That's OK.
Proven extensions could be mentioned freely. Mine is considered to be OK despite having some issues.
A lot of use, included myself, one day or other must develop a webapp in a shared host situatio.
We're good enough to install every thing,the code, but, what is the preferred strategy to create migrations in development environment (whre you have console access and can simply apply them in classic way) and then deploy into a server where you cannot access via console / ssh?
I'm trying since one whole week to use \yii\console\controllers\MigrationController from inside a standard webapp action (advanced template). I'm of course not able to do this.
Help we all, please, add someting to the official doc or at least a step-by-step newbie-ready post into the wiki.
Note: i cannot run exec and similar from php, them has been disabled from server admin.