Zend Gdata include path issue (Loader.php) - php

I've been trying to install Zend Gdata. I'm running from a dev environment so have access to php.ini.
I've set the include path and when I run the verification script I get the following..
Ran PHP Installation Checker on 2011-04-28T02:25:20+00:00
PHP Extension Errors Tested
No errors found
Zend Framework Installation Errors Tested
No errors found
SSL Capabilities Errors Tested
No errors found
YouTube API Connectivity Errors Tested
No errors found
But when I try to run any of the demo files I get the floowing error...
Warning: require_once(Zend/Loader.php): failed to open stream: No such file or directory in /usr/lib/php/ZendGdata/demos/Zend/Gdata/blogger.php on line 37
Fatal error: require_once(): Failed opening required 'Zend/Loader.php' (include_path='.:/usr/lib/php') in /usr/lib/php/ZendGdata/demos/Zend/Gdata/blogger.php on line 37
The most logical conclusion is that there is a problem with the include path, but I have checked it and it seems right.
Here's what I have for it...
.:/usr/lib/php/ZendGdata/library/Zend:/usr/lib/php/ZendGdata/library/
Any suggestions would be greatly appreciated.

Put this in the beginning of Blogger.php
set_include_path('/usr/lib/php/ZendGdata/library' . PATH_SEPARATOR . get_include_path());
You say you're setting the include path in a configuration file but that doesn't seem to be affecting CLI. Make sure you're editing the right php.ini file with php --ini

$clientLibraryPath = 'ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);
if you do not know the root path of the server, use relative path for accessing library. Its pretty handy to use.
above two lines should be written on the top of any file{page1,page2,page3} having folder structure as below
Website
Page1.php
Page2.php
Page3.php
ZendGdata
You can use your relative path as per your need

Related

php include_path error - pulling from servers include path and not user's path

I have a cpanel account on a shared server and I am having an issue using context_document_root because it is trying to pull the files from the actual server's include_path and not my specific user accounts include path. I need to figure out what is going on.
Here is the error:
Warning: include_once(): Failed opening '/WMS/configuration.php' for inclusion (include_path='.:/usr/local/lib/php') in /home/kylej/public_html/index.php on line 4
The file is located in public_html/WMS/configuration.php and is actually there.
In my htaccess: I've added RewriteBase /~kylej/ and I even tried creating a php.ini file inside my root directory with ini_set('include_path', '/home/kylej/public_html'); in it.
Can someone please help?
Inside the .php file, here is my include: include_once($_SERVER['CONTEXT_DOCUMENT_ROOT'] .'/WMS/configuration.php');
Obviously, $_SERVER['CONTEXT_DOCUMENT_ROOT'] is resolving to a null / empty value. This is why you shouldn't add external dependencies to your app.
Use a path relative to __DIR__ instead, thus keeping your app portable.
include_once __DIR__ . '/WMS/configuration.php';
In /home/kylej/public_html/index.php, __DIR__ will resolve to /home/kylej/public_html.
Also, enabling proper error reporting and display would have alerted you to the fact that $_SERVER['CONTEXT_DOCUMENT_ROOT'] is not set.

YouTube API No such file or directory

I'm a PHP newb trying out the YouTube API demo at http://www.youtube.com/watch?v=LMhN6pCAZWo.
I have the google-api-php-client and yt-samples-php-master directories that he says to download at
www.mysite.com/video/google-api-php-client and
www.mysite.com/video/yt-samples-php-master
the search.php file is in yt-samples-php-master and I have replicated the video and set:
if ($_GET['q'] && $_GET['maxResults']) {
set_include_path("./google-api-php-client/src");
// Call set_include_path() as needed to point to your client library.
require_once 'Google_Client.php';
require_once 'contrib/Google_YouTubeService.php';
I can get to www.mysite.com/videos/yt-samples-php-master/search.php fine but when I search I get message:
Warning: require_once(Google_Client.php) [function.require-once]: failed to open stream: No such file or directory in /home/myusername/mysite.com/videos/yt-samples-php-master/search.php on line 17
Fatal error: require_once() [function.require]: Failed opening required 'Google_Client.php' (include_path='./google-api-php-client/src/') in /home/myusername/mysite.com/videos/yt-samples-php-master/search.php on line 17.
I noticed that the files Google make available have a typo require_once 'contrib/Google_YoutubeService.php';
should be require_once 'contrib/Google_YouTubeService.php';
but that doesn't seem to help. Any clues would be very gratefully received!
EDIT: I've also set 755 recursively through videos directory to sub-directories and files
It's late. but someone may be looking for this in future.
Solution:
Google's php client uses composer, so, you've to put the path to the autoload file.
Link: Google API PHP client
Remove or comment out require_once() methods for Google_Client.php & contrib/Google_YoutubeService.php
Rename class name from Google_YoutubeService to Google_Service_YouTube while instantiating
Just replace this ./ and try this following format
set_include_path("google-api-php-client/src");
Is google-api-php-client in the same folder as your project. Make sure you are setting the include to point to that directory. And that directory is 755'ed.
Also in latest (v1.0) php library they changed placing of sources to
require_once 'Google/Client.php';
require_once 'Google/Service/Youtube.php';
OK I've come back to this after a little while. I've managed to get the search.php example to work by:
In search.php changing the require statements to:
require_once './google-api-php-client/src/Google_Client.php';
require_once './google-api-php-client/src/contrib/Google_YouTubeService.php';
and commenting out the set_include_path and following two require_once lines.
This lead to a fatal error saying that class Google_Service_YouTube could not be found in Google_YouTubeService.php. In that file there was however a class called Google_YouTube_Service which I renamed and then it worked!

Using PEAR XMLRPC2 inside wordpress plugin

I am trying to run the PEAR XMLRPC inside a plugin function to do some validation. It is all working fine in a standalone app that in a folder on my server, but as soon as I put all the files into my plugin folder, the:
require_once 'XML/RPC2/Client.php';
doesn't work. The Client.php file return an error:
Warning: require_once(XML/RPC2/Exception.php) [<a href='function.require-once'>function.require-once</a>]: failed to open stream:
So i assume it has to do with relative vs non-relative files, but I can't seem to figure out why it works outside of wordpress just fine.
If I start changing all the
require_once 'XML/RPC2...
to be the absolute path on the server the errors start going away, but I feel like I shouldn't have to change the source of PEAR and XMLRPC to do what i need. Any Suggestions?
You could update the PHP include path:
set_include_path(get_include_path() . PATH_SEPARATOR . $pathToPearLibs);
require_once($pathToPearLibs . 'XML/RPC2/Client.php');
This will give PHP one more (correct) place to look after it attempts to load from the wrong place.

Help with PHP and filepaths

I am using windows right now but I need my script to work on windows or linux. I am working on a project which allows to upload video to youtube, the youtube library requires the use of Zend framework (unfortunately) so I am really trying to get it to work, with no luck.
So my page says
Warning: require_once(Zend/Loader.php) [function.require-once]: failed to open stream: No
such file or directory in
E:\Server\htdocs\clients\youtube2\demos\Zend\Gdata\YouTubeVideoApp\operations.php on line 37
I have Zend framework located at
E:\Server\htdocs\frameworks\Zend
I then try to set the include path so that the scripts have access to Zend, thats where my trouble starts. I try to use this...
$path = 'E:/Server/htdocs/frameworks/Zend/';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
But I still get the error that you see above, now that you can see the path of my script above and the path of my Zend, can someone show me how to set the include path to work correctly? Thanks for any help
I tried some suggestions with no luck so far. Here is my updated code and result
$path = 'E:\Server\htdocs\frameworks';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
echo get_include_path();
Gives this...
E:\Server\php\PEAR;E:\Server\htdocs\frameworks
So it appears my include path for zend is added, but it still says it cannot find it
Final Update!
It is working, just where I set the include path wasn't getting included into all the files, is there a way to set the include path and have it be available globally?
If you want to change the include path in php.ini, just change include_path. Check out this tutorial to find out about a myriad of ways of changing the include path.
E:\Server\htdocs\frameworks\Zend
versus
$path = 'E:/Server/htdocs/frameworks/Zend/';
might make a difference on your system? Try it with \ instead of /.

Zendframe work include path Error on Hosting

I am trying to implement oAuth using Zendframe work. The script is running great on my localhost whereas when i am hosting the same files on to server (online) it is giving me include path error. I am not figuring out what might be the problem.
Error : Warning: require_once(Zend/Http/Client.php) [function.require-once]: failed to open stream: No such file or directory in
Thank You
You have to add the path in which Zend Framework is installed to your include path:
set_include_path('/path/where/Zend/directory/is' . PATH_SEPARATOR . get_include_path());
The include path is where PHP searches when you include a script.
Also, it's likely that you may have to upload the Zend Framework to your hosting server, as your hosting provider may not have installed it.
Sounds like the location where Zend Framework exists on your local host is defined in the default include path of your PHP configuration, or you're setting some include paths specific to application environment.
Compare the output of your get_include_path() in development and production, to see where it goes wrong. You can add the path where the application can find the Zend files from with set_include_path(), eg:
set_include_path(
APPLICATION_PATH.'/../library'.
PATH_SEPARATOR.
get_include_path()
);

Categories