• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Separating distinct but related projects (modules)

#1
[eluser]bapobap[/eluser]
Hi there,

I have a project that has many different parts but they are all related. At the moment there are 4 separate CI installtions but it's becoming a headache, especially with shared code. I've looked into Modules etc but I'm not sure if it's the right solution. Hopefully someone can give some advice!

So I have four separate projects: website, admin backend, mobile version, api

Each are on a separate sub-domain in their own hosting environment, so domain.com, admin.domain.com, mobile.domain.com, api.domain.com.

All of them have access to each others files but they all have their own index.php, routes.php, config.php etc. They share helpers and models but also have their own. Some need certain ones autoloaded, some don't.

Basically I'd like

Code:
application
    - helpers
    - libraries
    - models
    - modules
        - website
            - config
            - controllers
            - helpers
            - libraries
            - views
        - admin
            - config
            - controllers
            - helpers
            - libraries
            - views
        - mobile
            - config
            - controllers
            - helpers
            - libraries
            - views
        - api
            - config
            - controllers
            - helpers
            - libraries
            - views


A request from domain.com should load things from the website module. A request from api.domain.com should load things from the api module.

The respective routes.php from the config folder would be used for each and they aren't usable from other domains, for instance a request to mobile.domain.com/adminmodule/secret_controller/ wouldn't work. When I load a view from a controller, it knows I'm talking about a view in that controllers module "space" and doesn't have to search for it to find a match.

I've probably not explained it very well so forgive me. Is this even possible, or am I going to have to roll my own?!

#2
[eluser]rogierb[/eluser]
It should work if you setup proper .htaccess for each subdomain that rewrites the url to match the right
module, preventing access to other modules through this rewrite

Every subdomain has to get its own index.php and .htaccess.

So a url like admin.domain.com/controller would route to application/admin/controller.

Edit:
Code:
RewriteRule ^(.*)$ index.php/admin/$1 [L]
//or
RewriteRule ^(.*)$ index.php/api/$1 [L]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.