Yii2 advanced on shared hosting


I like the structure of yii2-advanced, the seperation of frontend/backend/common and such. But problem is that in order to correctly deploy it, you need specific configuration of the server. And I have only shared hosting for now. I tried “yii2-practical” app, but there are still doubts about it’s structure. I wanted to ask if the idea I have is very stupid or not.

I thought about such structure










    [indent]index.php (with css, js, assets folders etc)


    [indent]web/ (and move backend entry script with assets here)[/indent][/indent]


Or should I stick with basic template and make backend as a module, like good old Yii1 style? Or just use htaccess to route backend/* to backend? But i would like not to have vendors and other folders in reachable location.

You can’t really do the advanced app on a shared host since you can only set a single DocumentRoot.

There are workarounds but these are a bit tricky because of renaming CSRF and remember me cookies in order to prevent collisions.

You can set up your own virtual environment for less than $10/mo. I really can’t see the benefit of shared hosting.

Thank you guys for your input! For not having virtual environments - well, it’s sometimes not developer’s but client’s decision. Lets stick with that - let’s say, we cannot have two document roots.

Samdark mentioned about workarounds, “hacks”(CSRF and cookies). Are there any other things to consider? I found this article in documentation: http://www.yiiframework.com/doc-2.0/guide-tutorial-shared-hosting.html but sadly the subject i’m talking about is not written.

Or maybe it’s still better to have let’s say all “backend” with it’s modules as a module in “yii2-basic” application? But it’s a bit “nasty” in my opinion.

I would recommend you to use vps for hosting your Yii app. It is much better than shared hosting. You will get better performance and security because of dedicated server. If you don’t have sysadmin skills to setup a server from scratch, then you can use Cloudways Yii hosting platform for that. Using this platform, you can instantly launch a server without have to manually install OS, stack or PHP.