Installing Yii2 Starter Kit under Localhost

2019-09-10 22:24发布

问题:

I am a complete newbie at Yii2 Frameworks and I have been recommended to install the Yii2 Starter Kit to get a web framework up fast (see https://github.com/trntv/yii2-starter-kit).

I am trying to install the kit in a local development environment with PHPStorm and the in-built web-server. I have followed all the (applicable) instructions in the setup guide here:

https://github.com/trntv/yii2-starter-kit/blob/master/docs/installation.md#important-notes

After installation, I can't seem to browse any of my localhost urls (http://):

localhost:63342/yii-starter-kit

localhost:63342/yii-starter-kit/backend

localhost:63342/yii-starter-kit/frontend

Nor if my PHPStorm startup folder is set to the "yii-startup-kit" project folder:

localhost:63342/

I seem to be left with an installation that has no index.php in the root project folder, nor in backend or frontend folders so hence when I browse anywhere I get a "The requested resource was not found on this server" error. Could someone tell me what I am missing? Is it a requirement to run under Vagrant/Docker (VMs?).

Thank you.

P.S. I have also seen this question: Error deploying yii2-starter-kit Yii2 installation, however from what I can see, the Yii Starter kit now works in a single domain mode.

回答1:

It appears that (for some reason) Yii2-starter-kit is designed to "rewrite" all the backend and frontend URLs. This implies that PHP's simple in-built server can't handle the task (without doing quite a bit of fiddling to implement a PHP-based rewrite rule).

In the end, installing Apache was the only solution to get the framework to work. This requires implementing the "virtual host" configuration mentioned in the Installation Guide.



标签: php yii2