Completely New To Yii, Question About Gii

Hi there.

Just checking out Yii 2.0, not having any experience with Yii before that and not much with other PHP Frameworks either.

I"ve been following this tutorial for a start:

http://www.yiiframework.com/wiki/490/creating-a-simple-crud-app-with-yii2-revised-12-20-2013/

And so far things worked alright, up to the point of:

[i]"Creating the Database Model

Now that our database table has been created we can create the mode associated to our posts table. To do this we’re going to use good old Gii, which has recieved a major update in terms of prettyness."[/i]

So, sorry for the silly question, but where is that Gii? It"s been installed over the course of the tutorial along with some other stuff, but how do I get to that view? If I call up the basic website, I still get an "Unable to resolve the request ""." which is described as to be expected in the tutorial. I found some Gii-related files in the vendor/yiisoft/yii2-gii/ directory.

Do I have to load the module at some place into my index.php or something to be able to see the Gii? Or what is it that I"m missing?

Thanks a lot for any help. :)

First of all, take a look on your config file, you’ll find something like


if (YII_ENV_DEV) {

    $config['modules']['gii'] = [

        'class' => 'yii\gii\Module',

        // 'allowedIPs' => ['10.211.55.2'],

    ];

}

If you’re running you test server on virtual machine or even external server, you’ll need to add extra param ‘allowedIps’ (commented in my example, not present in the original config) to allow access from your computer.

Then you can access gii on URL /gii if you have pretty urls turned on, or something like /?r=gii (i believe) if you’re not.

UPD: you can start with basic application tempate instead of creating all the stuff manually.

Take a look: https://github.com/yiisoft/yii2/tree/master/apps/basic

Checklist to confirm:

  1. “yiisoft/yii2-gii”: “*”, (composer.json, section ‘require’)

  2. ‘gii’ in modules (config/web.php)

  3. gii is active (not disabled by ENV check, not disabled by IP configuration)

Thanks, I"ll have a look at that.

That helped, thanks. I can now access Gii on that basic app, after having set the correct allowedIPs. The other tutorial keeps showing a "Unable to resolve the request " error. The tutorial mentions that this is a normal message to see at some point, but doesn’t specify at which point you shouldn’t encounter it anymore. I guess I just lack the experience to know that myself.

I’ll first try to find out where that comes from or how to fix it, and if that doesn’t work, I"ll just check out some other Yii 2.0 tutorials.

"Unable to resolve the request" = 404 not found (probably caused by URL misconfiguration).

For example, if you have action actionIndex in your SiteController and try to load url “site/indexx” or “sites/index” instead of correct “site/index” you’ll get this error.

Notice that camelCased controllers and actions should be requested using dash: /my-site/my-camel-cased-action".