Question

I've seen several CI implementation examples that claim you can put project folders under the "applications" folder for Codeigniter.

However I've not been able to see this work as promised.

Here is what I have done and what I would like to do - maybe you can help out. For the sake of argument my document root is /www/(It's not, but let's use it for for simplicity's sake)

I've put the codeigniter core in /www/corelib/codeigniter

I've put the codeigniter system folder in /www/ci_system

I've put the applications directory in /www/applications

I've put my "entry point" in /www/dd

Now let's say I have two projects : "dataentry" and "cpanel"

The ideas is that I can go to

h**p://mydomain/dd/dataentry // for the dataentry application and

h**p://mydomain/dd/cpanel // for the cpanel application.

IF I organize the dataentry and cpanel directories like this:

/www/applications/controllers/dataentry

/www/applications/controllers/cpanel

/www/applications/models/dataentry

/www/applications/models/cpanel

/www/applications/views/dataentry

/www/applications/views/cpanel

I can get this to work fine. However, what I would like to do is keep the model and view at the same level as the controller so that I would have the following:

/www/applications/dataentry/controllers

/www/applications/dataentry/models

/www/applications/dataentry/views

/www/applications/cpanel/controllers

/www/applications/cpanel/models

/www/applications/cpanel/views

This does not seem to work.

Any suggestions?

-CF

Was it helpful?

Solution 2

Okay - I've got this working as desired. I'll try to write up a more extensive "how-to" and will provide a link in the comments section.

I did not have to modify .htaccess anymore than CI requires - I was happy about that. My entry directory look like this:

/dd/index.php

The two key pieces are here:

list($blank, $webpath, $app) = explode('/', $_SERVER['REQUEST_URI']);
        $application_folder = $_SERVER['DOCUMENT_ROOT]."/applications/$app";

This allows a single index.php to handle all applications.

The part that I was missing is that appName must now also be the primary controller or be a directory within the controllers. (The real problem I had was that I was hacking so much that I had configurations and routes preventing me from realizing what I was actually seeing : Sometimes starting clean is imperative.)

OTHER TIPS

Does each application ("dataentry" and "cpanel") have their own main index.php file which defines the appropriate $application_folder variable?

Also - and I'm sure you've read the docs - but CodeIgniter's documentation states that the /applications directory (or directories, in your case) should exist under the /system directory as follows:

system/application/foo/
system/application/foo/config/
system/application/foo/controllers/
system/application/foo/errors/
system/application/foo/libraries/
system/application/foo/models/
system/application/foo/views/
system/application/bar/
system/application/bar/config/
system/application/bar/controllers/
system/application/bar/errors/
system/application/bar/libraries/
system/application/bar/models/
system/application/bar/views/
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top