yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.24k stars 6.9k forks source link

Doc request: please document a strategy to handle migrations without console access #6904

Closed realtebo closed 8 years ago

realtebo commented 9 years ago

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.

cebe commented 9 years ago

You could try doing something like this: https://github.com/yiisoft/yii2/issues/6853

realtebo commented 9 years ago

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!

realtebo commented 9 years ago

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

stepanselyuk commented 9 years ago

@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();
cebe commented 9 years ago

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

cebe commented 9 years ago

when running a console application in web context at least the following things have to be considered:

machour commented 9 years ago

Is it fine to mention https://github.com/samdark/yii2-webshell in the guide? (given that it's not under yiisoft/)

samdark commented 9 years ago

Yes. That's OK.

samdark commented 9 years ago

Proven extensions could be mentioned freely. Mine is considered to be OK despite having some issues.