Welcome Guest, Not a member yet? Register   Sign In
Please describe how to achieve the best structure
#1

[eluser]m_ologin[/eluser]
Hi,

I'm new here, and as I've travelled accross several CI tutorials, it seems that no-one agrees on what the best file structure should be. I see a lot of people moving the application folder to the root folder, I see some others create a public_html folder to put all assets in... (different reasons, simplicity or...)

Now, i've tried playing around with those different possibilities, but it quickly becomes confusing as to how to handle the config.php, .htaccess, routes.php and other config files...

What's the best practice for file structure? How should the config files be set?
#2

[eluser]jedd[/eluser]
Greetings, and welcome to the forums.

Quote:Now, i've tried playing around with those different possibilities, but it quickly becomes confusing as to how to handle the config.php, .htaccess, routes.php and other config files...

Okay .. if you follow the [url="http://ellislab.com/codeigniter/user-guide/installation/index.html"]installation and getting started[/url] bit of the guide, you can't really go wrong. It covers what you need to do a basic install.

The other stuff that you're talking about - well, that's if and when you want to do something a bit more special.

Have you got a basic instance cranked up and the welcome-to-codeigniter page on a web browser?

You don't really need to muck with .htaccess - that's only if you want to get rid of the index.php bit in your URL's.

And you don't really need to muck with routes.php - other than (and it's optional) you want to change the default controller. Of course, you may well do, as the default is probably not what you want. But it's a one-word change, and heavily documented in routes.php

I think start with a basic system, and start to get comfortable with that first, and then branch out into customising things as you get happier with the layout and the format of the config files.
#3

[eluser]m_ologin[/eluser]
Sounds good. Thanks for your prompt response. I'm happy to see that this framework has an active community.

Regards,
#4

[eluser]Michael;[/eluser]
Greets m_ologin,

I have found the best overall folder structure to be as follows:

/root
-> /administration
-> /core
-> /system
-> /public_html
-> -> /assets
-> -> -> /css
-> -> -> /images
-> -> -> /js
-> -> /uploads
-> -> /themes
-> -> index.php (points to core)
-> -> admin.php (points to administration)

This set up will allow you to use the same system folder for multiple applications, and if you ever run into a situation where you need multiple versions of the CI installed you can just tag a '_v1.7' or something to the end up of the system folder and thus run as thus as well.

Michael
#5

[eluser]MellanCOOLic[/eluser]
First of all, i must say that this is my first try with the CI. I have parse all the documentation needed.. watched movies.. and so on.

But I have encounter a probably verry simple to fix issue (for others). But i can't figure it out. So.. i decided to join this comunity for some help.

The thing is that someone else is helping me with html-ization. So... basicaly, i get the html's all done. But they are comming with relatives path like this:
Code:
<img src="images/header/img.jpg" width="728" height="90" />
So.. basicaly.. i'm not using img() from HTML Helper. Due to all the html's using this path, i had to create a folder on root directory named "images" and put there all the images file and folders. I don't have any problems with the locations of those files, but my problems is that html's are located in the system/application/views directory. So.. basicaly... when i'm opening one view with my editor in design mode.. i can't see any of those images.

The thing to do.. is moving all the image folder.. right in the views folder. This way, i will see html's corectly in my editor. But doing so.. is killing my view in browser. The browser will basicaly try to find some images according to the address displayed on browser. And CI is using his own rules for uri.

The question is ... what can i do so that i keep the images in the views file and redirect the image urls to that folder ? is there a rooting solution ? or .htaccess can do some magic ?

I apologies in advance for asking this probably dumb question.. but i could'nt figure it out myself.
#6

[eluser]MellanCOOLic[/eluser]
i still have not found a sollution for this and i really need a fix.. so.. can anyone help me with this minor subject ?

P.S.
I've posted here because i think it has some relations with the topic name.
#7

[eluser]gvillavizar[/eluser]
[quote author="MellanCOOLic" date="1237838665"]First of all, i must say that this is my first try with the CI. I have parse all the documentation needed.. watched movies.. and so on.

But I have encounter a probably verry simple to fix issue (for others). But i can't figure it out. So.. i decided to join this comunity for some help.

The thing is that someone else is helping me with html-ization. So... basicaly, i get the html's all done. But they are comming with relatives path like this:
Code:
<img src="images/header/img.jpg" width="728" height="90" />
So.. basicaly.. i'm not using img() from HTML Helper. Due to all the html's using this path, i had to create a folder on root directory named "images" and put there all the images file and folders. I don't have any problems with the locations of those files, but my problems is that html's are located in the system/application/views directory. So.. basicaly... when i'm opening one view with my editor in design mode.. i can't see any of those images.

The thing to do.. is moving all the image folder.. right in the views folder. This way, i will see html's corectly in my editor. But doing so.. is killing my view in browser. The browser will basicaly try to find some images according to the address displayed on browser. And CI is using his own rules for uri.

The question is ... what can i do so that i keep the images in the views file and redirect the image urls to that folder ? is there a rooting solution ? or .htaccess can do some magic ?

I apologies in advance for asking this probably dumb question.. but i could'nt figure it out myself.[/quote]

Hi, try copying your images inside your views (in your local folder) and in your root (in your remote folder), so you will have two different image folders but while developing you will be faster. After you're finished. Just delete the folder in your views.
#8

[eluser]MellanCOOLic[/eluser]
That's an easy sollution.. and is exactly what i'm using right now.. but i thought there are other sollutions more "hdd friendly" then that Smile

thx anyway... and i'm still looking for a sollution nicer then duplicating my image folders
#9

[eluser]jedd[/eluser]
Howdi,

Well, it's up to you where you want to keep your image files. But wherever they are, you need to be consistent with that.

If you are running on a *nix server, you could keep them in one location, say outside of the CI / web directory, and provide a symlink back into your ../assets/images/ directory say.

I guess the important question for you is where do you actually store, or want to store, these images? Once you know for sure where this place will be, it will be easy to explain how to reliably and consistently refer to them in your code.

You might also want to give an example of a couple of lines in your code where you have referred to an image, and the browser is not displaying it.
#10

[eluser]MellanCOOLic[/eluser]
ok. i will give more explains about my problem:

this is how my directory system should look like:
-public_html
--system
---application
----views
-----images
-----css
-----view1.php
-----view2.php
-----view3.php
....etc...

due to the fact that i'm getting all the html's done by a friend, the views file (view1.php, view2.php, view3.php, etc.) have their images linked like this:
Code:
<img src="images/image1.jpg" width="240" height="9">

if i want to check the pages with my browser.. this is what my address looks like:
Quote:http://localhost/project/index.php/home
or
Quote:http://localhost/project/index.php/home.html

But all my images from the views.. are missing on browser.. because their link reference is looking like this:

Quote:http://localhost/project/index.php/images/image1.jpg

The question is:
Is there any way to make my images viewable in browser without interfearing with the phisical directory place and without changing their src link on each and every image from view1.php, view2.php, view3.php ...etc .. ?
Maybe a rooting.php sollution ? or an .htaccess one ?




Theme © iAndrew 2016 - Forum software by © MyBB