4
votes

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
Please check the file in that pathRamki
@Ramki the file exist in that pathHirad Roshandel
Try Include_once(path)Ramki
@MeeneshJain Giving 777 permissions on anything is asking for trouble, stop spreading bad advice!Ja͢ck
@HiradRoshandel change your code to use the correct path, specifically the case-sensitive correct path. *nix filesystems are typically case-sensitive. It's best to write your code in the most portable fashionPhil

2 Answers

4
votes

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.

2
votes

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";