Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,002 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,394 people online right now. Registration is fast and FREE... Join Now!




Apache - Unable to "include" files from parent folder

 
Reply to this topicStart new topic

Apache - Unable to "include" files from parent folder, Migraton from IIS to Apache

YoYo-Pete
9 Jan, 2008 - 11:42 AM
Post #1

New D.I.C Head
*

Joined: 21 Dec, 2006
Posts: 25


My Contributions
I am having much trouble getting a simple coding concept to work in a new environment and would appreciate some insight.

Senario: Root of web app stores "_application.php" This is a page that is required on the top of everypage. It checks on things and generates a nav menu that uses images. Modules for the app are stored in subfolders. Pages in the subfolders require the appliction file.
CODE
require '../_application.php';


This is standard coding practices I've used in IIS PHP application development, and hosted web site development. Bascially, create 1 menu or footer and include it on every user viewable page in the root and sub folder. I have never run into this not working.


Now I am in a new environment (new job) and this does not work. I get the following errors: (This is from a sandboxed development instance so I can change configs and figure this out for the production environment)

---Begin Error Message---
Warning: main(_MenuTop.php) [function.main]: failed to open stream: No such file or directory in c:\Program Files\Apache Group\Apache2jh\htdocs\PathPortal\TestChange\index.php on line 17

Fatal error: main() [function.require]: Failed opening required '_MenuTop.php' (include_path='.;c:\phpjh\includes') in c:\Program Files\Apache Group\Apache2jh\htdocs\PathPortal\TestChange\index.php on line 17
---EndError Message---


My co-workers tell me that this is standard out of the box functionality. I dont think it is, by default I thought you could include from a parent folder, as long as it was in the site.

I can verify safe mode is off.

I can't figure out what the reason for this is.

Anyone seen this before?

This post has been edited by YoYo-Pete: 9 Jan, 2008 - 11:44 AM
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Apache - Unable To "include" Files From Parent Folder
9 Jan, 2008 - 11:53 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,435



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Rather than go up one directory, why don't you add that directory in to the include path?

CODE

//(include_path='.;c:\phpjh\includes')
require '../_application.php';


CODE

//(include_path='.;c:\phpjh\includes;c:\phpjh\includes\rootpath\')
require '_application.php'; // <-- located in c:\phpjh\includes\roothpath\ or where-ever you like

User is online!Profile CardPM
+Quote Post

YoYo-Pete
RE: Apache - Unable To "include" Files From Parent Folder
9 Jan, 2008 - 12:00 PM
Post #3

New D.I.C Head
*

Joined: 21 Dec, 2006
Posts: 25


My Contributions
I was toying with it, but that would mean recoding a bunch of stuff.

That is my last resort. I'm more concerned on why this functionality is the way it is.
User is offlineProfile CardPM
+Quote Post

YoYo-Pete
RE: Apache - Unable To "include" Files From Parent Folder
16 Jan, 2008 - 08:21 AM
Post #4

New D.I.C Head
*

Joined: 21 Dec, 2006
Posts: 25


My Contributions
My solution ended up setting up a generic includes folder in my PHP installation.

My app is modules that are contained in folders off the root of the app. I was going to put a virtual directory in each folder to point at the main media folder off the root, but because this was apache, it required config changes and what not, which mean change control hoops to jump through.

Instead I passed path informtion in variables and used those to hard code paths instead of using relative paths.

My web dev roots are in CFML, so my methodoligies use the concept of the "application.cfm" page. While PHP doesnt have this (that I know about), I am manually using a require_once at everypage to fake it.

Kudos to no2pencil who had it right. At this point I've got a great framework up and running. Thanks!
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Apache - Unable To "include" Files From Parent Folder
16 Jan, 2008 - 08:33 AM
Post #5

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 6,435



Thanked: 64 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
Good to hear that you got it working!

That's the pain with automated systems... when they don't work you have to clean up their mess.
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 12:20PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month