Welcome Guest, Not a member yet? Register   Sign In
Directory placement
#1

[eluser]HeartlandTech[/eluser]
I'm working on creating an application, I'm using the CodeIgniter structure, but instead of having an individual project for each application, I'm using the following structure:

---> CodeIgniter
---> Applications
---> AppName_DEV
---> AppName_PROD
---> AppName_TEST

The index.php file decides based on the URL what application base to use:

Code:
// Just add to this to determine the live URL's for the site.
    $live_domain_array = array("localhost","appnameprod");
    // Just add to this to determine the test URL's for the site.
    $testing_domain_array = array("appnamedev");
    
    switch(true)
    {
        // ***************************************************
        // **   D E V E L O P M E N T   S E R V E R         **
        // ***************************************************
        // First see if we're on on the live server
        case in_array(strtolower($_SERVER['HTTP_HOST']),$testing_domain_array):
            {
                $application_folder = "application/appname_dev";    
                $GLOBALS['server'] = 'test';
                break;    
            }
        // ***************************************************
        // **   T E S T   S E R V E R                       **
        // ***************************************************
        // First see if we're on on the live server        
        case in_array(strtolower($_SERVER['HTTP_HOST']),$testing_domain_array):
            {
                $application_folder = "application/appname_test";    
                $GLOBALS['server'] = 'test';
                break;    
            }
        // ***************************************************
        // **   P R O D U C T I O N   S E R V E R           **
        // ***************************************************
        // First see if we're on on the live server            
        default:
            {
                $application_folder = "application/appname_prod";    
                $GLOBALS['server'] = 'production';
            }
        
    }

What I'm looking for a way to do is to handle where the /images,/css,/js can live without interferring with the directory structure. Right now I have everything in the main codeigniter area, but any changes are reflected immediately in all three environments. (http://myappname/images/new_logo.jpg for example.) I want the referenced files to be under their respective application directory.

Any ideas?
#2

[eluser]markwatson[/eluser]
Can't you just make something like public_html_dev and public_html_live, and then just change your web server to use the different roots for production or development?

Honestly tho, I don't get what you're trying to do... But why don't you use subversion or git and then just do branches for development/testing versions of the site? Then you can store all your files in a normal CI dir structure and deploy easily. BAM. everything will work magically :-p
#3

[eluser]HeartlandTech[/eluser]
Doing things this way leaves the main codeigniter branch clean and just allows you to update the applications directory . . which it was my understanding of how the CI structure was designed to work. I have things setup like this so that I don't have to worry about pointing one to another, my code figures out what the request URL was and uses the right directory structure and database.

I think I figured a way around this:

define('APPASSETS', '/' . APPPATH . "assets/");

So then my structure looks like this:

—-> CodeIgniter
—-> Applications
—-> AppName_DEV
--> assets
--> images
--> css
--> js
—-> AppName_PROD
--> assets
--> images
--> css
--> js
—-> AppName_TEST
--> assets
--> images
--> css
--> js
#4

[eluser]Tom Schlick[/eluser]
i dont understand why you are doing it this way and not just doing subdomains or svn but thats besides the point. why not just put all your images/assets ona subdomain and call them in from that
#5

[eluser]HeartlandTech[/eluser]
It's for an internal web application, so the host will be only referenced internally:

http://myapp_dev -- for development
http://myapp -- for live
http://myapp_test -- for testing against live data

If you build the files right you never have to touch one to change if your using CVS/SVN, because the files will figure out what domain your asking for and apply the correct configuration file, thus directory structure, and database. It works very slick in a production environment . . . it's not much use for single websites or such.




Theme © iAndrew 2016 - Forum software by © MyBB