RE: [PHP] Fixing the path

2009-09-14 Thread Arno Kuhl
-Original Message-
From: Rico Secada [mailto:coolz...@it.dk] 

Some time ago I developed a small web application that a bunch of users has
installed.

I have always used the DOCUMENT_ROOT for my includes, but the other day I
installed the application in a subdirectory, and as you've guessed a lot of
the includes didn't work.

I have been reading up on the subject of absolute vs. relative paths etc.
And on the subject of defining your own document root.

I need the application to be as user friendly as possible, and I would like
to avoid having users enter path details in the configuration.

What is the best way to solve this problem?

Rico.
--

Who are your users? Can users download the script and run it on their own
servers? If so there shouldn't be a problem asking them to set a path in a
config file because presumably the users would know something about servers
and paths, and presumably they'll know enough to create the directory and
copy the files there in the first place.

If you have an install process you can pick up the current directory from
system globals and write it to the path setting in the config file. You
might need two different absolute paths, one for includes and one for urls.

Cheers
Arno


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Fixing the path

2009-09-13 Thread Rico Secada
On Sat, 12 Sep 2009 00:43:50 -0400
Paul M Foster  wrote:

> (Or maybe I've completely misread what you're trying to do.)

Yes you did, but never mind :)
 
> Paul
> 
> -- 
> Paul M. Foster
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Fixing the path

2009-09-11 Thread Paul M Foster
On Sat, Sep 12, 2009 at 06:18:50AM +0200, Rico Secada wrote:

> Hi.
> 
> Some time ago I developed a small web application that a bunch of users
> has installed.
> 
> I have always used the DOCUMENT_ROOT for my includes, but the other day
> I installed the application in a subdirectory, and as you've guessed a
> lot of the includes didn't work.
> 
> I have been reading up on the subject of absolute vs. relative paths
> etc. And on the subject of defining your own document root.
> 
> I need the application to be as user friendly as possible, and I would
> like to avoid having users enter path details in the configuration.
> 
> What is the best way to solve this problem?

Don't move your files to a subdirectory if they're written to be in the
document root (and vice versa). ;-} Seriously.

There really isn't a way around this. All your files need to be in the
same places at all times relative to each other. You can use absolute
paths or relative paths; it doesn't matter. But the files themselves
can't be moved. The only alternative to this is to write a search
function which searches in fixed locations for files until it finds
them. And that's kind of silly.

Look at it this way: Major frameworks all specify their subsidiary files
to be in certain fixed locations. They'll have directories for
javascript files, directories for internal classes, directories for
configuration files, etc. They may or may not use relative pathing to
refer to those files, but the files themselves must be in a certain
location with respect to each other, always.

My convention is to set up fixed directories for each type of file (as
mentioned above) and then always put files of that type in those
directories. Then use relative or fixed pathing as desired from other
files that include() those files.

If you're using a front controller, then you can use PHP server
variables to get the path to that file, and use that as the reference
for the location of the other files.

(Or maybe I've completely misread what you're trying to do.)

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Fixing the path

2009-09-11 Thread Rico Secada
Hi.

Some time ago I developed a small web application that a bunch of users
has installed.

I have always used the DOCUMENT_ROOT for my includes, but the other day
I installed the application in a subdirectory, and as you've guessed a
lot of the includes didn't work.

I have been reading up on the subject of absolute vs. relative paths
etc. And on the subject of defining your own document root.

I need the application to be as user friendly as possible, and I would
like to avoid having users enter path details in the configuration.

What is the best way to solve this problem?

Best regards.

Rico.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php