Welcome Guest, Not a member yet? Register   Sign In
multiple application desgin question
#1

[eluser]hellomoto[/eluser]
Hi every one, according to here. we can manage multiple aplications under application/ folder.
Now i have such a problem, can these apps share same libraries and models?
what should i do?
#2

[eluser]brianw1975[/eluser]
technically yes, they should be able to share the same models and libraries.

I did the following:

Place the CI base code in (linux based dev environment)

Code:
/usr/share/pear/CodeIgniter
(I used pear because it should already be in the includes directive for PHP)


I used the following structure for my system:
Code:
/home/project_name/application - the application directory from the codeigniter dist -- note that this is above all of the public resources for a bit of added security without having to modify the living heck out of the .htaccess file.

/home/project_name/public_html - the public html directory

with:

/home/project_name/public_html/images/
/home/project_name/public_html/css/
/home/project_name/public_html/js/
(all of the public resources)

/home/project_name/public_html/index.php
/home/project_name/public_html/.htaccess

finally i set the following:

Code:
in /home/project_name/public_html/index.php

$system = "/usr/share/pear/CodeIgniter/system";
$application_folder = "/home/project_name/application";

Further down I had to comment out the following code (for two reasons: A) some reason my servers (yes multiple) would not see my application directory as a directory and determined the wrong APPPATH and B) I set my $system and $application_folder as absolute paths and not relative):

Code:
if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

With the above, you *should* be able to add models and libraries to /usr/share/pear/CodeIgniter/system/ and have access to them in your CI-based applications.

The above configuration should provide the following:

1) easy project/code management using git/svn/cvs etc
2) prevents users (or yourself) from screwing with the base CI code - forcing you to code more properly by extending existing CI classes
3) makes the git/svn/cvs repository smaller.
4) Future Upgrade of CI in one place vs many places.
5) is WAY easier than the tutorial in the Article on the CI website.
6) takes up less space on your server
7) updating your application on production servers is a lot easier

And more reasons that I am not thinking of right now.

Anyways, hope this helps.
#3

[eluser]hellomoto[/eluser]
@brianw1975
thank you very much Smile. i will keep this in mind.
As i understood . common libs and models should be added under system folder. after reading your post, looked to system directory, there is not exist model directorySad . but library exists.
do i have to add it(model folder),and extend loader class?
#4

[eluser]brianw1975[/eluser]
ah, this is my fault, I was going from memory and forgot that models aren't in the system folder - probably because models are typically very application oriented.

Extending the Loader class could do it, I'm not that familiar with the Loader class.

I would be interested in seeing what you come up with.




Theme © iAndrew 2016 - Forum software by © MyBB