Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php.ini include_path

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:

  1. What to put in the quotes of the include path setting itself.
    For example, if I wanted to add C:\wamp\www as an include path, would it be
    include_path = ".;C:\wamp\www\"?
  2. 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"
like image 685
Kevin Pei Avatar asked Feb 18 '12 23:02

Kevin Pei


People also ask

What is Include_path PHP?

The PHP Include Path is a set of locations that is used for finding resources referenced by include/require statements.

How do I know which PHP INI is being used?

Check php. ini in CLI (Command Line Interface): To know about php. ini, simply run on CLI. It look for Loaded Configuration File in output for the location of php.

What is relative path in PHP?

Relative pathsIf you don't supply the root, it means that your path is relative. The simplest example of relative path is just a file name, like index. html . So one should be careful with relative paths. If your current directory is /about/ then index.


2 Answers

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"
like image 147
thenetimp Avatar answered Sep 22 '22 03:09

thenetimp


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.

like image 37
Mike Purcell Avatar answered Sep 18 '22 03:09

Mike Purcell