No such file or directory PHP Google Calendar - php

set_include_path("google-api-php-client/src/google");
require_once 'Client.php';
require_once '/Service/CalendarService.php';
Results in:
Warning: require_once(Google/Auth/AssertionCredentials.php): failed to open stream: No such file or directory in D:\xampp\htdocs\xampp\GoogleCalendar\google-api-php-client\src\Google\Client.php on line 18
Fatal error: require_once(): Failed opening required 'Google/Auth/AssertionCredentials.php' (include_path='google-api-php-client/src/google') in D:\xampp\htdocs\xampp\GoogleCalendar\google-api-php-client\src\Google\Client.php on line 18
Please let me know where I am going wrong.

Assuming I'm in my /home/user/analytics directory (a blank directory) when I download the analytics API through git:
git clone https://github.com/google/google-api-php-client.git
I get these errors when I try to use Client.php. I've modified
/home/user/analytics/google-api-php-client/src/Google/Client.php like so; add four lines before the require lines:
$dirArray = explode('/', dirname(__FILE__));
$homeDir = $dirArray[2];
$path = '/home/' . $homeDir . '/analytics/google-api-php-client/src/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);

Related

php require failed to open stream:

I'm having a problem regarding the access to ros ezpdf using composer
Now i want using the green file (requisicoesDiarias.php) showed in the image, i want to access the red one (dbconfig.php) to get the result from a query and then show this result in a pdf (blue folder)
What i have until now is this
include_once '../../../db/dbconfig.php';
require_once __DIR__ . '/../vendor/autoload.php';
set_include_path('../vendor/ros/ezpdf/src/' . PATH_SEPARATOR . get_include_path());
I have the following errors
Warning: include_once(/home/ebspma/public_html/gest/pages/multimedia/pdf../../../vendor/autoload.php): failed to open stream: No such file or directory in /home/ebspma/public_html/gest/pages/multimedia/pdf/requisicoesDiarias.php on line 7
Warning: include_once(/home/ebspma/public_html/gest/vendor/ros/ezpdf/src): failed to open stream: No such file or directory in /home/ebspma/public_html/gest/pages/multimedia/pdf/requisicoesDiarias.php on line 8
I have put a file in that folder ros->ezpdf->src to get current path and i have this
/home/xxxxx/public_html/gest/vendor/ros/ezpdf/src
any help?

phpsec lib path is not working from cron job

The file path for my script is
/var/www/html/MyProject/index.php
when I run the script as
~/./Myproject$ php index.php its runs perfectly
When I run the script as
~$ php /var/www/html/MyProject/index.php
It does not read the phpseclib file path
My index.php file is
<?php
include("crud.php");
include("functions.php");
set_include_path(get_include_path() . PATH_SEPARATOR . 'phpseclib');
include('Net/SFTP.php');
...
?>
error:
PHP Warning: include(Net/SFTP.php): failed to open stream: No such file or directory in /var/www/html/MyProject/index.php on line 6
PHP Warning: include(): Failed opening 'Net/SFTP.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear.:/usr/share/php:/usr/share/pear/phpseclib') in /var/www/html/MyProject/index.php on line 6
PHP Fatal error: Class 'Net_SFTP' not found in /var/www/html/MyProject/index.php on line 186
How to run the php script form cron job?
From the error message, you can see that phpseclib is not being added to the include path correctly. Try this for the set_include_path instead:
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . DIRECTORY_SEPARATOR . 'phpspeclib');
The __DIR__ will take into account the location of the file you're executing, rather than trying to find phpspeclib relative to the current working directory.
You can try placing phpseclib1.0.12 library to the /usr/share/ or if you are running from the Project then you can try adding like this:
set_include_path('/var/www/html/phpseclib1.0.12');
include('Net/SFTP.php');

require_once :failed to open stream error: no such file or directory

$conn = mysql_connect($servername,$dbusername,$dbpassword) or die(mysql_error());
mysql_select_db($dbname) or die ("could not open db".mysql_error());
require_once dirname('../tcpdf/config/lang/eng.php');
require_once dirname('../tcpdf/tcpdf.php');
error: Warning: require_once(../tcpdf/config/lang): failed to open stream: No such file or directory in C:\xampp\htdocs\jmb_system\anggerik\printunitstmt.php on line 33
Fatal error: require_once(): Failed opening required '../tcpdf/config/lang' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\jmb_s
Kindly where is the error? Thanks
Use something like
require_once dirname(__FILE__) . "/path/to/file";
where
dirname(__FILE__)
means current file path.
Very usefull for relative including.
Don't forget the first slash
dirname('/../tcpdf/config/lang/eng.php');
dirname() gives you the path of the directory (in this case '../tcpdf/config/lang'). Require_once needs the file. Just remove the dirname().
require_once('../tcpdf/config/lang/eng.php');
require_once('../tcpdf/tcpdf.php');
or, if the "tcpdf" folder is in the same directory:
require_once('./tcpdf/config/lang/eng.php');
require_once('./tcpdf/tcpdf.php');
Try:
$filename = realpath('../tcpdf/tcpdf.php');
var_dump($filename);
What does it return? If it returns bool(false), the path/file doesn't exist here.

php set_include_path drives me crazy

I need to include a file in php so I do
$web_proc = '../res/proc'; //variable read from config file I can't change
//in my file
include_once($web_proc . '/check_sprache.php');
and PHP outputs:
Warning: include_once(../res/proc/check_sprache.php): failed to open
stream: No such file or directory in
/Users/user/Sites/site/res/pdf/rechnung.php on line 62
Warning:
include_once(): Failed opening '../res/proc/check_sprache.php' for
inclusion (include_path='.:') in
/Users/user/Sites/site/res/pdf/rechnung.php on line 62
So I change the include path:
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . DIRECTORY_SEPARATOR);
and try it again, but PHP outputs:
Warning: include_once(../res/proc/check_sprache.php): failed to open
stream: No such file or directory in
/Users/user/Sites/site/res/pdf/rechnung.php on line 62
Warning:
include_once(): Failed opening '../res/proc/check_sprache.php' for
inclusion (include_path='.::/Users/user/Sites/site/res/') in
/Users/user/Sites/site/res/pdf/rechnung.php on line 62
But if if I do
include_once(dirname(__DIR__). DIRECTORY_SEPARATOR . $pfadweb_proc . '/check_sprache.php');
it works. But this is no solution, since the included file includes more files with a relative path, so they are alse not found.
So either I misunderstand the PHP include path, or it's just trolling me.
Can anybody help?
The include path looks odd in the second example; You have two PATH_SEPARATOR characters and a trailing DIRECTORY_SEPARATOR though I doubt this is the problem.
Try this one out instead
set_include_path(implode(PATH_SEPARATOR, [ // use array() if PHP < 5.4
dirname(__DIR__), // this should be /Users/user/Sites/site/res
get_include_path()
]));
include_once 'proc/check_sprache.php';
This will add the parent directory (/Users/user/Sites/site/res) of the CWD (/Users/user/Sites/site/res/pdf) to your include path.
Any include statements in any other files can use a relative path from /Users/user/Sites/site/res.

Zend Loader Problem

Well this question maybe asked for hunderds time. But I could not make it work.
There is my directory list:
--main/
---- Zend/
---- dir1/
---- dir2/
And this is my set include path configuration:
set_include_path(PATH_SEPARATOR
. dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Zend' . PATH_SEPARATOR
. get_include_path());
I also try adding all directories seperatly to the path.
But apache insists on giving these error:
Warning: require_once(Zend/Loader.php): failed to open stream: No such file or directory in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\main\Zend\Translate.php on line 25 Fatal error: require_once(): Failed opening required 'Zend/Loader.php' (include_path=';C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\main\Zend;.;C:\php\pear') in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\main\Zend\Translate.php on line 25
Which is thrown from the php file which is in dir1 on these lines:
include_once '../Zend/Locale.php';
include_once '../Zend/Translate.php'; //this is the line
How can I solve this problem?
As you have a relative to current file include path, one of the two Zend classes, which is running:
require_once 'Zend/Loader.php';
is resolving to htdocs\main\Zend\Zend\Loader.php
To fix, remove the DIRECTORY_SEPARATOR . 'Zend', then also your include_once's can be
require_once 'Zend/Locale.php';
require_once 'Zend/Translate.php';
Note I changed to require_once as include_once will carry on the script even if the include fails, which is not recommended.

Categories