Dynamically run console commands?

Is it possible to somehow run the "model" and "crud" command line statements from within Yii?

Is this something that can be done by accessing or extending Gii? I haven’t had the time to dig into Gii yet so please excuse me if it is blatantly obvious there.


Well, you can use exec or curl for execute a command or get a webpage, so you can run this commands…

The question is: what for?

If I understand you, you are thinking about the "model" and "crud" command used in yiic…

Gii is a replacement for just that… take a look at the documentation - http://yiiframework.com/doc/guide/1.1/en/quickstart.first-app#implementing-crud-operations

I have some scenarios where I want to be able to dynamically expand my application based on a preset definition. So all the information that the model and crud commands need would already be available, I just need to run the commands. I’ve tried using exec, however because the yiic shell is interactive I couldn’t figure out how to format the commands so that the shell actually got the command.

Gii I know is a replacement for the command line, however it is also an interactive webpage.

What I’m looking for is something more like (overly simplified and hopeful :D):


It must exist somewhere in the Gii code, I just thought I’d ask before digging through lots of code.