What is the point of the CLI webapp generator?

I’m new to Yii. I’m eager to learn and understand several things about it. First off, I’m trying to understand what the point is, of using the CLI to generate a webapp.

Following along in various tutorials, after downloading Yii, the first thing you do is generate the default webapp with the CLI tools. If generating the webapp always generates the exact same code every time you use it, then what is the point of generating it? Why isn’t the webapp code just included in the source that you download and “install” on your webserver? Generating something implies that you are using a creating something that is going to be different depending on a bunch of input variables. But the generator makes the same thing. Every time. What is the point of that?

The only thing I can think of is that it’s possible to customize the webapp template so that you can maybe generate different types of webapps? I could see that being helpful. Is this possible? If not, back to the original question. What is the point?

Gii Generator is customizable, you can create your own templates and use them on your projects.

As an example,

If you have specific requirements on your model, then create a customized model in Gii templates for this projects or others.

In my case, i have my own:

class CMyActiveForm extends CActiveForm {


then, every time i need a CRUD, it will be created using my own template, and this template use CMyActiveForm and takes advangate using my own methods.

@Jakobud: I think one advantage of using CLI webapp generation ensures that (at the time you use it) relative paths in index.php for instance are correct.

@bluyell: A little note: Question is about CLI not Gii


That makes sense. I just dived in yiic and yiic.php when using console (for crons) and it seems customizable

The point is …

Take a look at ‘WebAppCommand.php’ in yii/framework/cli/commands/ and it should be revealed to you what it does. :)

What I usually do is create another ‘CostomAppCommand.php’ in that folder and add a new directory in yii/framework/cli/views/ which contains a set of files which usually makes up the web apps that I want generated.

And then I just do a yiic customapp blahblah instead.

Perhaps it will be a good idea to add a functionality for crating application profiles that developers can install and get started. similar to Drupal

Let me re-take the OP question here:

What would the main benefit of Option a) be:

"Using customWebApp to generate those applications"?


Option b):

"Create several application types" clone (or copy/paste them) and change accordingly.

Taking into consideration that:

  1. you still have to change the main.php configuration file accordingly (like db access, etc), on option a as well.

  2. you don’t (at least I don’t see where) have to change any PATH on option b. Some of you do talk about PATH benefits, I don’t recall, on option b, of any PATH that needs to be edited.

What is, again, the true benefit of using webapp or custom webapp, over clone or copy/paste, even on "several base applications" scenarios?"

What am I not seeing?