473,467 Members | 1,291 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Appending to the include_path

Is it possible in, say, a .htaccess file, to append additional paths
to the php include_path without knowing what the value of include_path
is beforehand? I want to add an absolute path to a directory and it's
subdirectories from a .htaccess file, but I don't want to have to
encode the entire current value of it and append my own path as that
would mean having to change it every time it changes in php.ini or the
code is deployed on a different server.
Aug 1 '08 #1
4 3792
Gordon wrote:
Is it possible in, say, a .htaccess file, to append additional paths
to the php include_path without knowing what the value of include_path
is beforehand? I want to add an absolute path to a directory and it's
subdirectories from a .htaccess file, but I don't want to have to
encode the entire current value of it and append my own path as that
would mean having to change it every time it changes in php.ini or the
code is deployed on a different server.

I suppose everyone works differently. I always have a site config file
that I include on every page. This has all the site or project specific
paths and functions in it. I usually put the database handle in this
also. That way when I want to move this code to a new server or domain,
I just change the paths and the database settings in this common config
file.

Jeff
Aug 1 '08 #2
On Aug 1, 9:57 am, Gordon <gordon.mc...@ntlworld.comwrote:
Is it possible in, say, a .htaccess file, to append additional paths
to the php include_path without knowing what the value of include_path
is beforehand? I want to add an absolute path to a directory and it's
subdirectories from a .htaccess file, but I don't want to have to
encode the entire current value of it and append my own path as that
would mean having to change it every time it changes in php.ini or the
code is deployed on a different server.
AFAIK, no.

However, you could set an auto-prepend in the htaccess file which
reads the current value and then sets a new value including the
original.

Personally, I usually go with having a standard lib required in every
file which searches the current dir then up through the dir hierarchy
till it finds a file with a particular name (e.g.
'ht_php_conf.inc.php') and requires it if found. The overhead for this
is surprisingly small compared with requiring a file with a pre-
declared path.

C.
Aug 1 '08 #3
*** Gordon escribió/wrote (Fri, 1 Aug 2008 01:57:59 -0700 (PDT)):
Is it possible in, say, a .htaccess file, to append additional paths
to the php include_path without knowing what the value of include_path
is beforehand? I want to add an absolute path to a directory and it's
subdirectories from a .htaccess file, but I don't want to have to
encode the entire current value of it and append my own path as that
would mean having to change it every time it changes in php.ini or the
code is deployed on a different server.
You can always do it in PHP itself:

<?php

echo 'Before: ' . ini_get('include_path') . "\n";
include('file_in_foo.php');

ini_set('include_path', ini_get('include_path') . ';C:\\Foo');

echo 'After: ' . ini_get('include_path') . "\n";
include('file_in_foo.php');

?>
If you don't have a general configuration file in your site where you can
place this stuff, you could even use the auto_append_file PHP directive to
automatically include a script.

Just make sure you don't get lost; it happens pretty often with automagic.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aug 1 '08 #4
*** Álvaro G. Vicario escribió/wrote (Fri, 1 Aug 2008 18:03:32 +0200):
If you don't have a general configuration file in your site where you can
place this stuff, you could even use the auto_append_file PHP directive to
automatically include a script.
Sorry, typo: it's auto_prepend_file; I copy-pasted the wrong line...

http://es.php.net/manual/en/ini.core...o-prepend-file
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor en cubitos: http://www.demogracia.com
--
Aug 1 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ramprasad A Padmanabhan | last post by:
I know it is a dummies question, But I am not able to find it on the php manual. Can anyone tell me How to set the include_path in php thanks Ram
3
by: mirko | last post by:
Hello, I have a problem with my include_path and I don't know why... Can anybody see the mistake? my configuration: PHP Version 4.3.11 System: Windows NT 5.0 build 2195
24
by: Paul | last post by:
I am taking over an existing app and having trouble understanding their references. They have encapsulated Pear packages in the directory structure like: /site /site/html/Pear.php...
10
by: Schraalhans Keukenmeester | last post by:
I suspect the following problem IS hosting provider specific, but they haven't been able to help me out so far. Perhaps I am doing something wrong and someone is able to spot the issue... Here...
0
by: Bastien Continsouzas | last post by:
I am trying to set the include path for SimpleTest under Eclipse I have the following config : Eclipse : 3.2.0 PHPEclipse 1.1.8 SimpleTest plugin : 0.2.1 I ran a test I found on the...
9
by: Charles Crume | last post by:
Hello Everyone; My site was hacked the other day -- someone was able to rename my index.shtml file and put their own index.html file on my server. Not sure how it was done, but looking through...
2
by: Rob Wilkerson | last post by:
Hey all - I'm trying to create a developer-friendly environment on my production server. By that, I mean an environment where developers don't need to worry about certain things. Among those...
1
by: hoobert | last post by:
Hi all -- I have an include_path question. Just setting up a new server, and I'm running into a really stupid issue. I have the following line in php.ini: include_path =...
0
by: mukeshrasm | last post by:
Hi! I want to use phpmailer class to send mail using smtp.I have downloaded the phpmailer and then i followed it's README file where it is mentioned that "Copy class.phpmailer.php into your php.ini...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.