PHP's include
and require
functions aren't limited to your webroot; they can range across your whole filesystem. Therefore the root, i.e. "/" directory that include paths refer to is generally the root of the disk/volume/whatever that your including PHP file is on.
This is different from the "document root" of your website, which effectively maps a root URL to a particular directory.
So, to include your file using an absolute path from the root, you'd need:
require_once '/Applications/MAMP/htdocs/include/phpexcel/Classes/PHPExcel/IOFactory.php'
Often, people will use relative paths to avoid needing long paths like this, and to make their code easier to move. So if the file you're doing the require_once
in is:
/Applications/MAMP/htdocs/test/kvitto/index.php
...then you should find that this works:
require_once '../../include/phpexcel/Classes/PHPExcel/IOFactory.php'
Because stepping up two directories from kvitto
, where your index.php is, gets you up to htdocs
, and you can then descend from there.
PHP has lots of mechanisms to make this easier. You can use the __DIR__
magic constant ("current directory name") in include paths, or go the whole way and roll your own autoloader for classes if you want.