4

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();
16
  • Please check the file in that path Commented Jun 18, 2015 at 4:25
  • @Ramki the file exist in that path Commented Jun 18, 2015 at 4:26
  • Try Include_once(path) Commented Jun 18, 2015 at 4:28
  • 1
    @MeeneshJain Giving 777 permissions on anything is asking for trouble, stop spreading bad advice! Commented Jun 18, 2015 at 5:20
  • 1
    @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 fashion Commented Jun 18, 2015 at 5:20

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

7 Comments

still same error : Failed opening required '/var/www/html/libraries/Stripe/init.php'
does it have anything to do with composer?
@HiradRoshandel Then the file is simply not there; if you used composer to install packages in that non-standard directory, then you need to run it again on the other server.
Urgh, it's case sensitivity. See the comment here ~ stackoverflow.com/questions/30906376/…
@HiradRoshandel Did you actually use Composer to install the Stripe package?
|
2

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

1 Comment

but I had this code on another server and it was working properly! there has to be something wrong in my setting

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.