Is there a way to set the include_path at runtime? The directory structure of my development machine is different from my (future) webhost's directory structure. I don't even know if I can update the webhost's php.ini file. I am assuming the worst (i.e. cannot update).

Hence, what is the best way to make the include_path as "independent" as possible? I don't want to hardcode the path in all my include() and require() statements as this is obviously not a good idea if I change webhosting environments.

Thanks.

    5 months later

    Hai,

    If someone has the answer to this question please let me know.
    I've got exactly the same problem.

    Thanks in advance.

      2 months later

      check out the "ini_set" command. havent used it myself but came across it ...

      hope it helps

        Hi Aris,

        Thanks for the info.
        In my case the server had disabled the ability to change the include path.

        Thanks again.

          19 days later

          Hi,
          I've just got the same problem.
          Haven't thought much about this yet, here are my initial ideas (in case ini_set doesn't work):
          Write a script in which you define the base directory as a constant e.g. define("BASE_DIR", "/here/there/");
          and include this in all your files you need. After it's been read, you can write: include(BASE_DIR . "classes/foo.php");

          The problem is, that you must edit this constant any time you move your site.
          I tried to do some string magic to make this process dynamic. The problem I haven't work around yet is that if you try to get the path of your script, you get the one that references your init script.
          example:

          page.php:
          include("util/init.php");

          init.php:
          $SCRIPT_FILENAME = page.php, not util/init.php

          I fear the same problem is present with ini_set as well.
          Any workaround?

          Hope this helps. Any better idea?

          bye, Peter

            Hi Peter,

            Thanks for the input.

            It has been a while since i started this tread, and i solved the problem partially already.

            At the moment i\'m having a vacation so i\'m can\'t try out some stuff. Next week i will get back to this matter. You probably solved the problem yourself by than.

            I don\'t understand the dynamic part of your workaround completely, but i wil try to next week.

            Thanks again for your efford.

            p.s. sorry for the misspellings.

            Eelco

              Hi Eelco,
              ini_set works for me, so I'm ok, but perhaps I can help you if you still need it.
              bye Peter

                Hi Peter,

                I don't realy need to solve the problem anymore, it works good enough as it is.

                Thanks anyway.

                Eelco

                  In httpd.conf (I use Apache webserver) I have had some luck with this:

                  php_value include_path "path:path:path"

                  Of course, it sounds like everyone has their own solutions already.

                    10 days later

                    Hi,
                    well it's ok, but the problem was to set the path at runtime. What's more I'm not the root at the server, so I don't have access to httpd.conf.
                    Thanks anyway :-)
                    bye, Peter

                      Write a Reply...