Cannot set PHP include_path

5.3k views Asked by At

I have uploaded all my files in var/www/html and in one of my php files I have this line :

require_once('libraries/stripe/init.php');

the structure of my folders are list this:

www
 -html/
       -libraries
           -> Stripe -> init.php
       -register.php

I keep getting this error message:

Warning: require_once(libraries/Stripe/init.php): failed to open stream: No such file or directory in /var/www/html/register.php on line 116

Fatal error: require_once(): Failed opening required 'libraries/Stripe/init.php' (include_path='.:/usr/share/php:/var/www/html/') in /var/www/html/register.php on line 116

my php.ini file used to be like this

include_path= ".:/usr/local/php/pear/"

but based on some answers here i changed it to

include_path='.:/usr/share/php:/var/www/html/'

but it's not working!

Edit: in my libraries folder I have file called index.php the content is:

<?php 
header("Location: ../"); die();
2

There are 2 answers

7
Ja͢ck On BEST ANSWER

I wouldn't leave library paths to chance like that:

require_once(__DIR__ . '/libraries/Stripe/init.php');

This would make sure you include the script using the absolute directory path of the currently running script.

Update

Failed opening required '/var/www/html/libraries/Stripe/init.php'

Well, then the file is simply not there; if this file was generated by some other tool, e.g. composer, it would need to be done again on a new server (or ideally at every deployment).

i think the problem is my Stripe folder is in "s" but I'm using capital "S". is there anyway to make not case sensitive?

File systems under Linux are case sensitive by default (not even sure whether it can be changed) as opposed to Windows. Make sure you use capitalisation consistently.

1
Shivaram Mahapatro On

That not what you are looking for. it says that php.ini file can't find the path of the file that you specified. that's why you should use absolute path to the file

require_once "path/to/file";