Welcome Guest, Not a member yet? Register   Sign In
How easy is it to share data between apps?
#1

[eluser]ThomasOwens[/eluser]
I haven't tried this yet, but I hope to experiment more with this framework over this long weekend. Anyway, let's say I have this structure:

-home
--index.html
--system
---cross application code (login support, user profiles, etc)
--blog
---index.php
---system
----a blog application and it's stuff
--forums
---index.php
---system
----a forum application and its stuff

Can the blog and forum applications call views and such from the "home" system? Each is a stand alone application, but shares things like user profiles and whatnot. I want to put the shared code into home application and then application specific code into the other categories.

A related question is can I have multiple copies of index.php, each with a different name? For example, a forum.php and a blog.php in the same directory, each with it's own models, views, and controllers (most likely in differently named "system" directories).

Thanks to anyone that helps! Smile
#2

[eluser]Pascal Kriete[/eluser]
I'll start from the bottom as that part is pretty straight forward.

You only need one system directory, which can drive several applications. The path to the system and application directories is set in index.php. See managing apps for more info.

You can have as many index.php files as you want, but you won't be able to complete remove any of them with mod rewrite (that would cause an obvious conflict). However, blog.php/controller/function and stuff.php/controller/function can coexist quite peacefully.

Which brings me to the first part of your question. You will not be able to load files from the 'base application'. If you're looking for this type of separation I suggest you give Matchbox a try.

Some stuff can be shared however, such as the database, cookies (and with that - sessions), etc.

Hope that helps and welcome to CodeIgniter.
#3

[eluser]ThomasOwens[/eluser]
[quote author="inparo" date="1215147739"]I'll start from the bottom as that part is pretty straight forward.

You only need one system directory, which can drive several applications. The path to the system and application directories is set in index.php. See managing apps for more info.

You can have as many index.php files as you want, but you won't be able to complete remove any of them with mod rewrite (that would cause an obvious conflict). However, blog.php/controller/function and stuff.php/controller/function can coexist quite peacefully.
[/quote]

The second part of your answer I get, but I want to clarify this.

I can have multiple system directories, if I want to, correct? I do want some isolation between my apps, and the ability to remove or replace them as necessary.
#4

[eluser]Pascal Kriete[/eluser]
Sure you can, but there is no point. What most people do is move the application directory out of the system directory. Put the system below your webroot (you could do the same with the application folder) and then just have multiple index.php files and application directories.

Example:
- system
- forum (an application folder)
- blog (another app)
- main_app (app)
- htdocs (webroot)
-- index.php (for main app)
-- blog
--- index.php (for blog - by putting it in a subdirectory they can all be wiped with mod rewrite)
-- forum
--- forum_index.php (doesn't really matter what you name them)

EDIT: to clarify - by putting it in a subdirectory I think it's clearer where stuff goes, you can rewrite them all in one directory.
#5

[eluser]ThomasOwens[/eluser]
Ah. I think I get it. Is this right (or even close)?

Example:
-webroot
--system
---cache
---codeigniter
---database
---(everything else except application)
--index.php (your homepage, not the CI index.php)
--forums.php (the CI index.php configured for the forums app)
--blog.php (the CI index.php configured for the blog app)
--random dir
--random dir
--forums (CI app)
---config
---controllers
---errors
---(the other dirs in CI application directory)
--blog
---the dirs in CI application directory)
#6

[eluser]Pascal Kriete[/eluser]
You got it. system/application moves and gets duplicated. The application/system paths in each index file are corrected. And upgrading CI becomes easy as pie.
#7

[eluser]ThomasOwens[/eluser]
And this way, things like sessions and cookies can be reused across applications. For example, providing a unified login system (which might be it's own "user" application, along with things like user profiles and whatnot). Thanks for the help.




Theme © iAndrew 2016 - Forum software by © MyBB