Welcome Guest, Not a member yet? Register   Sign In
A simple newbie question about installation and multiple apps
#1

[eluser]Doug Lerner[/eluser]
This is a very newbie question.

In the install instructions it says:


Unzip the package.
Upload the CodeIgniter folders and files to your server. Normally the index.php file will be at your root.
Open the application/config/config.php file with a text editor and set your base URL. If you intend to use encryption or sessions, set your encryption key.
If you intend to use a database, open the application/config/database.php file with a text editor and set your database settings.

My questions are,

(1) Where should you put the files if you intend to develop multiple applications?

(2) Is the set of folders and files supposed to be duplicated for each application?

(3) A site will normally already have an index.html. Do you really want index.php at the root of the site even if an index.html already exists there?

Thanks,

doug
#2

[eluser]Michael Wales[/eluser]
Quote:(1) Where should you put the files if you intend to develop multiple applications?
To host multiple applications you seperate the /application directory from the rest of CodeIgniter. Go ahead and move that directory to the same level as /system

Now, move the index.php file from /system to /application

Finally, make a copy of /application and name it /application2

Your folder structure should be:
/system
/application
/application2

You now have 2 seperate applications running on the same CodeIgniter framework (found within the system folder) - you just need to make a few slight changes in index.php, which is heavily documented.

Quote:(2) Is the set of folders and files supposed to be duplicated for each application?
Yes, each application folder will be a duplicate of other applications - in structure. The framework (within the system folder) will only reside in one place. Speaking of which, I highly recommend moving this above your webroot so it is not accessible by others.

Quote:(3) A site will normally already have an index.html. Do you really want index.php at the root of the site even if an index.html already exists there?
Your index.html will not be used, the index.php will be called first. Of course, this can be changed within your Apache config.
#3

[eluser]Doug Lerner[/eluser]
Thanks for your reply, Michael. I believe I understand what you are suggesting.

This is actually pretty exciting. I've been looking at both RoR and CodeIgniter. All the things in RoR that seemed so mysterious to me while going through some tutorials, seem much clearer in CodeIgniter. Probably because the introductory documentation and step-by-step instructions are so well written and are easier to follow. Like "Oh! So all the URL means is that the next segment is the controller, the one after that is the function in the controller and all the ones after that are just ordered arguments to the function being called. Why didn't Rails just say so?"

Not to mention the fact that you don't need to occasionally change to the terminal and run some mysterious script to continue.

I also like the fact that I simply took my structure from my Mac and plopped it right on to my hosted ISP and and just worked.

CI seems to be very flexible. Thanks for your explanation.

Since posting my note I noticed from the docs that you can also separate controllers into folders of controllers and just add the folder name to the URL. So that is also almost like having a separate app - at least for testing. As long as you don't mind sharing the database between the tests.

Even with one app, though, would you still recommend the file structure you mentioned, and moving the system folder above the webroot? What happens if it is accessible?

Thanks!

doug
#4

[eluser]Michael Wales[/eluser]
I would definitely recommend the structure I mentioned. Any good framework will recommend you do the same as well - it's just a security risk, you don't want your framework available to the rest of the world.

By moving index.php within your application folder (and changing the application_folder variable to '.') and then moving the system folder up above your webroot/public_html (and changing the system _folder to '../system' or '../../system' - whatever) you instantly increase the security of your application significantly. With absolutely no drawbacks - plus, if you ever decide to throw another CI application on that host - you already have the framework right there!

It also makes it really easy to upgrade the framework. I have my framework folder name 'ci-1.6.3' - when a new version comes out, I'll dump it out there, switch over my apps on at a time and confirm they work as expected. If not, I can pick and choose which version of the framework each app uses (at least I can work on the app to get it compliant with the latest version).
#5

[eluser]Doug Lerner[/eluser]
That's a very good point about being able to pick and choose the framework for each app like that. I am convinced. Smile

Thanks,

doug
#6

[eluser]Doug Lerner[/eluser]
Michael, I have one quick followup question. I did what you suggested (I feel so organized now!) and it works if I set the system_folder setting as:

$system_folder = "../../../ci-system-1.6.3";

because I renamed system ci-system-1.6.3 and placed it at the very top, just above public_html and that's where it is relative to my new application folder. So that is all fine and well.

But I was wondering, why the following system_folder setting does not work:

$system_folder = "/ci-system-1.6.3";

If I were able to set the absolute path to the system folder, wouldn't that be even more useful? Then I could move the application folder around to anywhere and it would still work. If I move it to a different location now I have to remember to go in and change the system_folder setting.

Do you know how to make the system_folder setting absolute instead of relative?

Thanks,

doug
#7

[eluser]Michael Wales[/eluser]
CodeIgniter will determine the absolute path to the system folder later on (it's at the bottom of index.php).
#8

[eluser]Doug Lerner[/eluser]
You mean at this point, right?

define('BASEPATH', $system_folder.'/');

and then

require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

But why can't $system_folder itself be “/ci-system-1.6.3” in order to allow reference to the absolute location, instead of the relative location?

Thanks,

doug
#9

[eluser]Pascal Kriete[/eluser]
You can reference an absolute location, but it needs to be a filesystem path.

So it will probably be something like this (on a unix host) : /home/username/folder/system
#10

[eluser]Doug Lerner[/eluser]
Ah. The real real absolute path. I didn't consider that. Thanks - I'll try to figure out what that is. It's probably documented somewhere in my cPanel or something. Thanks.

doug




Theme © iAndrew 2016 - Forum software by © MyBB