php.ini include_path
Solution 1
This all depends on what you are trying to accomplish. Personally, I don't edit the php.ini file directly for setting include_paths, rather I use the following construct, in code:
// This will append whichever path you would like to the current include path
// PHP is smart enough to convert / with \ if on a Windows box
// If not you can replace / with DIRECTORY_SEPARATOR
set_include_path(get_include_path() . PATH_SEPARATOR . 'my/custom/path');
-- Edit --
Chances are there may be multiple copies of php.ini on your system, and that you are not editing the one that is being used by PHP.
Solution 2
The php.ini file will have include_path already in it, but commented out, that is where you should put it, by uncommenting it. It also has examples for windows. It will look like this, just remove the semicolon preceding "include_path"
; Windows: "\path1;\path2"
;include_path = ".;c:\php\includes"
Kevin Pei
Updated on July 26, 2022Comments
-
Kevin Pei over 1 year
I've searched all over the place and can't seem to find an answer for this. I'm trying to set an include path in the php.ini file of my local wamp server. I currently don't understand one of two things:
- What to put in the quotes of the include path setting itself.
For example, if I wanted to addC:\wamp\www
as an include path, would it be
include_path = ".;C:\wamp\www\"
? - Where to put the include path line. Can I put it anywhere, or do I have to put it in a specific place?
Some common errors I've read about in my research that I've checked.
- I'm editing the php.ini file located at
C:\wamp\bin\php\php5.3.8
- I've restarted the server after I've made my changes and have checked if it had updated using the
phpinfo()
function.
UPDATE
This is currently what I have, but it still doesn't work.; Windows: "\path1;\path2" include_path = ".;C:\php\pear;C:\wamp\www"
-
markus about 12 yearsThe include path is correct and it shows when you call phpinfo(). So how can you say it doesn't work?
-
Kevin Pei about 12 yearsIt doesn't show in phpinfo for me for some reason... maybe it's my system or something
-
markus about 12 yearsAnd your phpinfo() also shows that the php.ini you're editing is actually the one which is loaded?
-
Leandri over 9 yearsApache reads from wamp\bin\apache\Apachex.y.z\bin\php.ini file. You should add the include_path to that php.ini file and restart your wamp services
- What to put in the quotes of the include path setting itself.
-
Kevin Pei about 12 yearsis this correct? ;
include_path = ".;c:\php\includes;c:\wamp\www"
-
Kevin Pei about 12 yearsI could use this as a temporary fix, but I would rather put it into the php.ini file, as I want the changes to be global without me having to add the code to every single file.
-
thenetimp about 12 yearsYes, but remove the ; from the beginning of the line ; is a comment in ini file syntax.
-
Mike Purcell about 12 yearsUnderstood. I use MVC so I set all include_path directives through one script and it affects the entire application.
-
Kevin Pei about 12 yearsIf anyone refers to this in the future, please look at the solution below. I've marked this as answer because he has solved it in a comment on the post I've made blow
-
ewroman over 9 yearsdid you restarted the php? or server?
-
Kirk Ross about 5 yearsI have my php7.3.3 installed in c:\php73 but there is no pear or includes folder in there... are you supposed to create an empty folder for php to use?