Mapping the Path

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jim Carlock

    Mapping the Path

    Any recommendations on the best way to map paths?

    require('./library/include/file1.php');

    works well for files in the root folder, but for files in another
    folder, I need to rewrite the path to the files, and sometimes
    when testing things on my personal system, they work there,
    but fail when uploaded to the website. Using the root...

    require('/library/include/file1.php);

    doesn't seem to work as I thought it would. It's like the
    server maps the '/' to something unknown. There a way
    to find out what '/' gets mapped to inside the require()
    function?

    Any suggestions? Thanks much.

    Messing with PHP 4.4.1 (Windows XP, Apache 1.3.34
    (Win32)) on my system and PHP 4.3.11 (Unix-Apache
    1.3.31) on the host.

    Jim Carlock
    Post replies to the newsgroup.


  • Janwillem Borleffs

    #2
    Re: Mapping the Path

    Jim Carlock wrote:[color=blue]
    > Any recommendations on the best way to map paths?
    >[/color]

    IMO, the most convenient way to do this is to add a php_value directive to
    the httpd.conf file:

    php_value include_path ".;C:/Path to includes dir"

    Or when using virtual hosts:

    <VirtualHost *:80>
    php_value include_path ".;C:/Path to includes dir"
    ...
    </VirtualHost>


    JW


    Comment

    • Janwillem Borleffs

      #3
      Re: Mapping the Path

      Janwillem Borleffs wrote:[color=blue]
      > IMO, the most convenient way to do this is to add a php_value
      > directive to the httpd.conf file:
      >[/color]

      Forgot to mention, with this added to the httpd.conf file, you can simply
      do:

      include 'whatever.php';

      From each location in and below the site's document root and whatever.php
      will be retrieved when it's either in the current working dir or in the
      defined include path (searched for in that specific order).


      JW


      Comment

      • Jim Carlock

        #4
        Re: Mapping the Path

        "Janwillem Borleffs" <jw@jwscripts.c om> suggested:[color=blue]
        > IMO, the most convenient way to do this is to add a
        > php_value directive to the httpd.conf file
        > php_value include_path ".;C:/Path to includes dir"[/color]

        Happy New Year! Thanks for the comment about php_value.

        I ran across the include_path item in a few pages at php.net.



        And the content of that page left me puzzled as to how or where
        to place that. Also, the Unix server that the site I'm deploying to
        is a hosting company. IS there a way to edit the httpd.conf file
        through PHP?

        And I'm trying to get some other things working to find out what
        modules are installed... tried...

        apache_get_modu les()

        but that particular item is failing on my local machine.
        apache_get_vers ion() works and returns the version.

        Also, found the include_path in the php.ini file. So that is
        probably what I'm looking for on the local Windows
        system. But will that work for the remote Apache (Unix)
        server when I don't know where or how to get to it ?

        The other things found in the php.ini file include:

        doc_root =
        user_dir =

        I'm thinking my problem is an Apache problem, and I need
        to create a couple virtual hosts.

        For the meantime I'm going to have to stick to 100% relative
        addressing for all my includes rather than using virtual root
        addressing.

        Unless there's a way to configure the doc_root variable to use
        use a different root for two or more virtuals.

        Again, thank you and Happy New Year to everyone.

        Jim Carlock
        http:// 70.124.31.73
        Post replies to the newsgroup.


        Comment

        • Janwillem Borleffs

          #5
          Re: Mapping the Path

          Jim Carlock wrote:[color=blue]
          > And the content of that page left me puzzled as to how or where
          > to place that. Also, the Unix server that the site I'm deploying to
          > is a hosting company. IS there a way to edit the httpd.conf file
          > through PHP?
          >[/color]

          Most configurations support .htaccess overrides, Just put a file called
          ..htaccess (so: dot htaccess) in de root of your webfolder and put the
          php_value directive in there.
          [color=blue]
          > And I'm trying to get some other things working to find out what
          > modules are installed... tried...
          >
          > apache_get_modu les()
          >
          > but that particular item is failing on my local machine.
          > apache_get_vers ion() works and returns the version.
          >[/color]

          Then, you probably installed PHP as CGI. On my system, where PHP runs as a
          module, there isn't any problem with this function.
          [color=blue]
          > Also, found the include_path in the php.ini file. So that is
          > probably what I'm looking for on the local Windows
          > system. But will that work for the remote Apache (Unix)
          > server when I don't know where or how to get to it ?
          >[/color]

          For this you should test the .htaccess approach mentioned before. BTW, this
          approach will also work on Windows systems.


          JW


          Comment

          • Steve

            #6
            Re: Mapping the Path

            On Sat, 31 Dec 2005 21:15:34 +0000, Jim Carlock wrote:
            [color=blue]
            > Any recommendations on the best way to map paths?
            >
            > require('./library/include/file1.php');
            >
            > works well for files in the root folder, but for files in another
            > folder, I need to rewrite the path to the files, and sometimes
            > when testing things on my personal system, they work there,
            > but fail when uploaded to the website. Using the root...
            >
            > require('/library/include/file1.php);
            >
            > doesn't seem to work as I thought it would. It's like the
            > server maps the '/' to something unknown. There a way
            > to find out what '/' gets mapped to inside the require()
            > function?
            >
            > Any suggestions? Thanks much.
            >
            > Messing with PHP 4.4.1 (Windows XP, Apache 1.3.34
            > (Win32)) on my system and PHP 4.3.11 (Unix-Apache
            > 1.3.31) on the host.
            >
            > Jim Carlock
            > Post replies to the newsgroup.[/color]
            require ( $_SERVER['DOCUMENT_ROOT'] . "/library/include/file1.php" );

            will allow you to access anything under docroot, which is probably the
            only stuff you can be sure of when on a shared server.

            Steve


            Comment

            Working...