Yii Framework Forum: Single codebase, multiple sites - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Single codebase, multiple sites Does Yii support this? And if not, what is the best way to go about it

#1 User is offline   edanb 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 32
  • Joined: 16-June 09

Posted 14 June 2010 - 03:53 AM

The idea is simple: I would like to have a single codebase, but support multiple domains pointing to it, each domain configured differently (even different database).

When I say domains configured differently, I mean that these can be completely different websites, not just different themes per website. So one site can be a job listing site, another can be an article submission site, etc, all using the same "core" that handles users, auth, common components etc etc.

I have started looking into this a bit, and it's obvious that the default way Yii works isn't suited for this. For one thing, I would need a "websites" table in database, which stores site-specific config. But in order to read this I need the db object configured, which is also site-specific (different sites can sit on different databases).

I thought about using the themes folder but calling it "sites" instead, and using it like a theme which also includes the site-specific config, etc. Then in sites I would have "sites/example.com", "sites/example2.com" etc, and in index.php I would need to read the site-specific config according to which domain has been accessed.

Another thing is that each site would have different controllers, actions, layouts etc, and therefore I thought of creating a SiteModule which is a type of module that pertains to a certain website "type". So I could have a jobs module for the job websites, an article module for the article websites, etc.

I am only starting to solve this problem, but I would be happy if anyone has any experience they may share, or even better, code that does something similar.

Thanks in advance!
0

#2 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,605
  • Joined: 17-January 09
  • Location:Russia

Posted 14 June 2010 - 10:19 AM

I wrote a tutorial about it http://yiiframework....ll.many.configs It's in russian, but code speaks by itself.
0

#3 User is offline   nancoder 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 14-June 10
  • Location:QuerĂ©taro, Mx

Posted 16 June 2010 - 01:10 AM

Hi, I just have posted an enviroment class, i think it will help you if you modify some parameters, you can check it out here EASY Enviroment Class
Configure your app enviroment with this Easy Enviroment Class

Follow me on Twitter | LinkedIn
2

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,605
  • Joined: 17-January 09
  • Location:Russia

Posted 16 June 2010 - 04:47 AM

nancoder
Nice solution.
0

#5 User is offline   nancoder 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 14-June 10
  • Location:QuerĂ©taro, Mx

Posted 16 June 2010 - 02:29 PM

Thanks for your comment samdark! Really appreciate it! I will upload this class to the cookbok, hope help other in their projects.
Configure your app enviroment with this Easy Enviroment Class

Follow me on Twitter | LinkedIn
0

#6 User is offline   dans 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 24
  • Joined: 21-October 10

Posted 02 December 2013 - 09:41 PM

nancoder, just stumbled upon your solution. Love it ! :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users