Multiple Yii2 sites

Hello to everybody,

i’m thinking about developing a new website with Yii2 Framework.

The website will have multiple subdomain with lot of share component and model. For example, all subdomains will have a blog and pages.

Now, i would like to understand if i can set up the common environment (eg the folders common, console, environments, tests, vendor) in the main domain (domain.com) and set up different application for each subdomain (first.domain.com, second.domain.com).

In this way, i would like to maintain only one Yii installation and not clone common model and controller.

Can Yii do it? What should i check for choosing the hosting (any idea about a good hosting to do that?)? What should i config?

Thanks

Yes, check out the advanced application template, as that’s exactly what it is.

1 Like

Thanks Dana!

So, as I read in Adding more applications, I can add multiple environment as I need.

If I understood correctly, i will have all the folder in the same point, so backend, frontend and blog.

But how can i configure them as subdomain? Eg, in my common/config/bootstrap.php i have

Yii::setAlias(‘backend’, dirname(dirname(DIR)) . ‘/backend’);

This means that the backend is accessible by www.mysite.com/backend. What should i do to have backend.mysite.com?

Thanks!!

It does not mean that - you are confusing path aliases with virtual hosts.

See:

http://www.yiiframework.com/forum/index.php/topic/69602-is-it-possible-to-rename-backend/page__view__findpost__p__295608

Actually, if you care to read the advanced template readme, it is all explained in it:

Perfect!!

Thanks jacmoe, i understood!!!