File Organization and Aliasing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

File Organization and Aliasing

Post by empiresolutions »

Hello all. I have been working on a Website/CMS (Engine) for a few years now. With every site i build, i just copy the current version of the Engine, make some minor changes and skin it to fit the perticular site i am building. This has worked well for a while. My problem is when i have to make an update. If i update or add an important feature to one site, usually i will need to add it to others that have the same Engine. So basically i have to waste a bunch of time updateing multiple site.

I have since learned about aliasing. So i have now seperated all my Engine into three sperate parts. (1) Site Engine. This is all site dependent files for a basic site. (2) Cart Engine. These are all files dependent on the shopping cart. (3) Manager Engine. This is the CMS for the site.

Before the seperation all files include() a *starter.php* file that initiates things like db connections, session control, and other various site dependent controls. My problem is now that i have seperated to three main Engines, only the Site Engine works. I had not forseen that the other two engines would now not have a way to connect, or know where the starter.php file is located.

My question is how can i now tell the file */path/to/ManagerEngine/index.php* that at line #1 calls <? include("starter.php"); ?>, that the file is at */path/to/site.com/starter.php*.

Ok I hope you all get what im asking. Thank you.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I'm afraid I don't understand.

are you trying to include a file whose path is relative to some engines but not others?

if so, just set a path variable for each page that includes that file and use that to direct php to the correct location.
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

Post by empiresolutions »

try to follow me..

1. /path/to/site.com/index.php has a link in it calling to /path/to/site.com/ManagerEngine/index.php.
2. Aliasing redirects to /path/to/ManagerEngine/index.php.
3. /path/to/ManagerEngine/index.php at line 1 is calling <? include("starter.php"); ?>
4. starter.php lives at /path/to/site.com/starter.php.

How do i link dynamically from /path/to/ManagerEngine/ to the calling directory before aliasing kicked in?

It was suggested to rename all my starter.php to *sitename_starter.php* and put them in the "include_path" defined in the php.ini file. If this works i will post my results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

just include the full physical path in your include.
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

Post by empiresolutions »

if in /path/to/ManagerEngine/index.php I set include to <? include("/path/to/site.com/starter.php"); ?> or hard code to <? include("http://www.site.com/starter.php"); ?> then how will site_a.com, site_b.com, and site_c.com be able to use path/to/ManagerEngine/index.php?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

This root level is closed by default on pretty much all servers. You will need to set permissions of the desired directory to allow PHP to view it.
empiresolutions
Forum Newbie
Posts: 20
Joined: Tue Apr 11, 2006 10:39 am
Location: Portland, Or

Post by empiresolutions »

My resolution was as follows, i am using a local example. This examples updates the location of the include path in the php.ini file.

1. Add a new directory, C:\apache2triad\htdocs\includes\. (You may also use an existing *include_path*)
2. Update *include_path* in php.ini file to also accept C:\apache2triad\htdocs\include\. The include_path will be looked in first when an *include()* is called from any file in localhost.

It was that simple for the first part of my Question. The second can be found in a post called "Linking Structures".
Post Reply