Welcome Guest, Not a member yet? Register   Sign In
one index.php for multiple application
#1

I am making multiple application in one CI installation, based on the CI user guide it said "Each of your applications will need its own index.php file which calls the desired application. The index.php file can be named anything you want.". I wonder if I can just make one index.php for all apps that I made on the CI installation.

is there anyone who can help me?
Reply
#2

It can probably be done, but you'd need to be able to figure out a way to detect which application is being called and set the appropriate $application path in index.php to point to the correct application.
Reply
#3

How are you planning on serving up the different applications?

Subdomains?
app1.somesite.com
app2.somesite.com

Urls?
somesite.com/app1/controller
somesite.com/app2/controller
Reply
#4

(05-01-2015, 08:24 AM)CroNiX Wrote: It can probably be done, but you'd need to be able to figure out a way to detect which application is being called and set the appropriate $application path in index.php to point to the correct application.
actually that is the reason I made the question. So far I try to search on google about how to setting the index.php for multiple apps in one CI, but the result is always about make different index.php files and rename them according the apps.
(05-01-2015, 08:35 AM)CroNiX Wrote: How are you planning on serving up the different applications?

Subdomains?
app1.somesite.com
app2.somesite.com

Urls?
somesite.com/app1/controller
somesite.com/app2/controller

subdomain.
Reply
#5

(This post was last modified: 05-01-2015, 02:18 PM by CroNiX.)

Maybe just checking the server name would suffice. However, that won't work if you ever need to access the app via CLI, like to run a cron job, since $_SERVER won't exist. Never tried to do what you're attempting, so not sure how feasible this is.
PHP Code:
switch($_SERVER['SERVER_NAME'])
{
  case 
'app1.domain.com':
    
define('APP_DIR''application/app1');
    break;
  case 
'app2.domain.com':
    
define('APP_DIR''application/app2');
    break;
}

//Could not determine app to run, die
if ( ! defined('APP_DIR'))
{
  die(
'Could not determine app');
}

//If we got this far, set the $application_folder
$application_folder APP_DIR
Reply
#6

(05-01-2015, 02:14 PM)CroNiX Wrote: Maybe just checking the server name would suffice. However, that won't work if you ever need to access the app via CLI, like to run a cron job, since $_SERVER won't exist. Never tried to do what you're attempting, so not sure how feasible this is.

Thanks for your help, atleast you give me another option.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB