简体   繁体   中英

Cannot set PHP include_path

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();

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, eg 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM