I've been trying to find the solution to my problem for DAYS. I couldn't find anyone to simply explain what to do to open stream with composer/any other library. It seems this is so simple, everyone knows how to do it.
my index.php
<?php
require 'vendor/autoload.php';
?>
error message:
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in /home/(webhostusername)/(subdomain.mydomain)/index.php on line 3
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/(webhostusername)/(subdomain.mydomain.com)/index.php on line 3
What else should I do? Do the composer files need to be in the same folder as my subdomain?
more information:
using Dreamhost shared hosting
installed composer via SSH
I want to use a library (raiym/instagram-php-scraper)
It is recommended to give a full path to the file you are trying to include.
require __DIR__ . '/vendor/autoload.php';
But you most definitely are trying to include a file that doesn't exist. Is the index.php file in a different directory than the vendor directory?
Related
I am struggling trying to figure out why my require path link is not working.
My folder setup is the following:
Main domain on server test.example.com.
public_html -> test.example.com -> PHPMailer -> PHPMailerAutoload.php
Since the main domain is test.example.com, I am putting test.example.com in the path url. I have to do this for any link on the site (it was a setup mistake, but I haven't changed it yet).
The way I am trying to access this folder is below:
require 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php';
I get the following errors:
Warning: require(test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Warning: require(test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php): failed to open stream: No such file or directory in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
Fatal error: require(): Failed opening required 'test.example.com/test.example.com/PHPMailer-master/PHPMailerAutoload.php' (include_path='.:/opt/cpanel/ea-php71/root/usr/share/pear') in /home/example/public_html/test.example.com/php/newsletterSend.php on line 4
I need the link to be an absolute path because the file will be used in different folders.
Does anyone see what I am doing wrong?
it looks like your php is in a directory above the phpMailer folder.. so i think the path would be "../PHPMailer/PHPMailerAutoload.php"
you can use absolute paths if its simpler:
/home/foo/public_html/test.example.com/PHPMailer/PHPMailerAutoload.php
or relative paths if you know where you're starting!
../PHPMailer/PHPMailerAutoload.php
I store my WordPress theme in my Dropbox to use it easily on many machines. Unfortunately require_once()/include_once() doesn't seem to work for me.
Is store original theme at G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\
The symlink is placed at C:\xampp\htdocs\blabla\wp-content\themes\Blabla
When I wanted to require/include any file, eg. C:\xampp\htdocs\blabla\wp-load.php I used to do require_once('../../wp-load.php');
But with symlink all I got is:
Warning: require_once(../../../wp-load.php): failed to
open stream: No such file or directory in
G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\foo\bar.php on line
2 Fatal error: require_once(): Failed
opening required '../../../wp-load.php'
(include_path='.;C:\xampp\php\PEAR') in
G:\Dropbox\Dropbox\Wordpress\Themes\Blabla\foo\bar.php on line
2
Looks like require_once looks for the file within the Dropbox, not symlink context? Is it possible to fix it somehow? I can't use absolute path as I develop on different machines / different OSes and those vary... Any ideas? How does require_once work when it's symlinked? Does it look for required file in both places (original-context & symlink-context)?
How about putting the original file into you Wordpress folder and symlinking to dropbox?
While installing this, you should turn off dropbox on all machines where you did not move the folder yet.
This error is quite common and it generally means it can't find the file it's looking for, but I can see the file in the directory?!
Full error:
Warning: require(/home/coinsfut/public_html/files/core.php) [function.require]: failed to open stream: No such file or directory in /home/coinsfut/public_html/new/index.php on line 4
line 4 says:
require $_SERVER['DOCUMENT_ROOT']. "/files/core.php";
the site is hosting in /new
any ideas?
Check the warning again. You are trying to include
/home/coinsfut/public_html/files/core.php
when in fact you want
/home/coinsfut/public_html/new/files/core.php
Please try
require $_SERVER['DOCUMENT_ROOT']. "/new/files/core.php";
and it should work just fine.
Alternative you could use
require "files/core.php";
to include files in a relative sub-directory since your index.php is in "new" directory.
I am having problems to go up and down in folders using both relative and absolute path. Everything I try giver me an error:
failed to open stream: No such file or directory in C:\wamp\www\project\Telas\Funcionario\IncluirFuncionario.php
When I try using "dirname(FILE)" it returns a warning:
Warning: include_once(C:\wamp\www\qrFoodManager\Telas\Funcionario/../../Seguranca/VerificarAutenticacaoSubTela.php): failed to open stream: No such file or directory in C:\wamp\www\qrFoodManager\Telas\Funcionario\IncluirFuncionario.php on line 2
When I try relative paths, it gives me a warning like:
Warning: include_once(../../Seguranca/VerificarAutenticacaoSubTela.php): failed to open stream: No such file or directory in C:\wamp\www\qrFoodManager\Telas\Funcionario\IncluirFuncionario.php on line 2
This is the project tree (open on eclipse Helios): http://img268.imageshack.us/img268/5593/y3l3.png
I am trying to include VerificaAutenticacaoSubTela.php in IncluirFuncionario.php; currently using Wamp Server 2.4 installed on C: .. Help please!
Use $_SERVER['DOCUMENT_ROOT']
<?php include_once($_SERVER['DOCUMENT_ROOT']."/project/Seguranca/VerificarAutenticacaoSubTela.php"); ?>
include_once(dirname(__FILE__).'/../../Seguranca/VerificarAutenticacaoSubTela.php');
Try this
<?php
include_once($_SERVER['DOCUMENT_ROOT']."/project/Telas/Seguranca/VerificarAutenticacaoSubTela.php");
?>
*Note: * Assuming the path where the files are is: /project/Telas within your wamp/www
I include a file in my php document but on local side and on server side it is not including i use require but it is also not working and an error show on the screen.. I checked the path 100 times it is right. The error is this:
Warning: require(../library/config.php) [function.require]: failed to open stream: No such file or directory in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3
Warning: require(../library/config.php) [function.require]: failed to open stream: No such file or directory in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3
Fatal error: require() [function.require]: Failed opening required '../library/config.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/logics/public_html/clients/creativecellutions/farnelo/files/header.php on line 3
Please help me to resolve this.
This is my code:
<?php
require ("../library/config.php");
require ("../library/functions.php");
?>
require(../library/config.php)
Is pointing to the wrong location in your directory. Get the location of config.php relative to the position of the file this script is calling. That should resolve the error.
your code will try to include a file located at
/home/logics/public_html/clients/creativecellutions/farnelo/library/config.php
are you sure that is the currect location of the file?
if it is then the only ussue possible is that you do not have permission to read the file with php.
I guess you are not directly running clients/creativecellutions/farnelo/files/header.php and including this in some other file index.php or something else and that's where the problem may be.
Try using relative path require_once( dirname(__FILE__) . '/../library/config.php' );
Try using getcwd() function.
That is
include(getcwd()."path to config.php");