本文介绍了Youtube API所需的设置Zend框架路径的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我复制了&将此文本粘贴到此处.似乎编辑器似乎会随机格式化某些部分. ;)

I copied & pasted this text here. It seems the editor seems to format some parts randomly. ;)

我下载了ZendGdata 1.9.6,并将其解压缩了.上载到我的网站根文件夹...,我需要将其与Youtube API配合使用才能将视频下载到我的网站上.我必须说我是这一切的新手,因此,考虑到这一点,我将不胜感激.

I downloaded ZendGdata 1.9.6, extracted it & uploaded it to my site'sroot folder ..., which I need for use with Youtube API to get videos onto my site.I must say I’m new to all this, and so I would appreciate taking this into account.

库文件夹位于/ZendGdata/library.

The library folder is at /ZendGdata/library.

我遇到的问题是步骤. 3当我按照指示进行操作时( http://code.google .com/intl/de-DE/apis/gdata/articles/php_client_lib.html#gdata-installation )

The problem I'm having is Step. 3 when I follow instructions(http://code.google.com/intl/de-DE/apis/gdata/articles/php_client_lib.html#gdata-installation)

为此目的进行设置.

  1. 下载Google Data Client库文件.
  2. 解压缩下载的文件.四个子目录应为创建:
    • demos —示例应用程序
    • 文档—客户端库文件的文档
    • library-实际的客户端库源文件.
    • tests-用于自动测试的单元测试文件.
  1. Download the Google Data Client Library files.
  2. Decompress the downloaded files. Four sub-directories should becreated:
    • demos — Sample applications
    • documentation — Documentation for the client library files
    • library — The actual client library source files.
    • tests — Unit-test files for automated testing.

除了.htaccess文件外,建议的添加路径之一是在php.ini中.我的网站位于共享主机上.我无权访问php.ini主文件,但如果需要我可以创建一个文件.对于Drupal CMS,对于某些功能,只需在根文件夹中放置一个即可.

One of the suggested locations to add the path, apart from the .htaccess file is in php.ini.My site is on shared hosting. I have no access to the main php.ini file, but I’m allow to create one if I need one. For Drupal CMS, for some functions, it suffices placing one in the root folder.

我添加了这一行:

include_path=".:/usr/lib/php:/usr/local/lib/php:/home/habaris6/
public_html/site.root.folder/ZendGdata/library";

但是,当我转到mysite.com/ZendGdata/demos/Zend/Gdata/InstallationChecker.php来测试设置时,如关于YouTube的文档,出现错误:

When I however go to mysite.com/ZendGdata/demos/Zend/Gdata/InstallationChecker.php to test the set up, like is mentioned in thedocumentation on Youtube, I get the error:

PHP Extension ErrorsTested No errors found

Zend Framework Installation Errors: Tested 0

Exception thrown trying to access Zend/Loader.php using 'use_include_path' = true.
Make sure you include Zend Framework in your include_path which currently
contains: .:/usr/lib/php:/usr/local/lib/php

SSL Capabilities Errors: Not tested

YouTube API Connectivity Errors: Not tested

所以我的问题是:这是将库文件夹的位置添加到您的PHP路径"的正确方法吗?我有点不知所措.

So my question is: Is that the correct way to "Add the location of the library folder to your PHP path" ?I’m a bit mixed up.

有人说php.ini文件仅在其所在的文件夹中处于活动状态.如果是这样,哪个ZendGdata文件夹应该具有它?正如我所说,我的目的是要正确设置一个Zend框架以允许使用Youtube API,这也是我必须学习的方法.

Someone was saying the php.ini file is only active in the folder where it is located. If that is the case, which of the ZendGdata folders should have it?As I said, my purpose is to have a the Zend framework properly set up to allow using Youtube API, something I also yet have to learn to do.

在Google Youtube API小组中,我被引荐.下载的文件&附带的文档前提是zend.com的知识远比像我这样的初学者要多.

In Youtube API Google group, I was referred here. The documentation coming with the downloaded file & at zend.com pre-supposes, one knows much more than some beginners like me.

另一个人说我尝试放置这个

Another person said I try placing this

$clientLibraryPath = '/home/habaris6/public_html/site.root.folder/ZendGdata/library';
$oldPath = set_include_path(get_include_path() . PATH_SEPARATOR . $clientLibraryPath);

在mysite.com/ZendGdata/demos/Zend/Gdata/InstallationChecker.php

in mysite.com/ZendGdata/demos/Zend/Gdata/InstallationChecker.php

虽然我之前尝试过的所有方法都失败了,但第一次测试除外,当我将上述代码片段放入安装检查器中时,我对所有内容均获得了积极的测试:

Whereas everything I had tried before failed, except fot the first test, when I placed the above snippet in the installation checker, I got positive tests for everything:

Ran PHP Installation Checker on 2009-12-09T21:16:08+00:00

PHP Extension ErrorsTested: No errors found

Zend Framework Installation Errors Tested No errors found

SSL Capabilities ErrorsTested No errors found

YouTube API Connectivity ErrorsTested No errors found

这是否意味着如果我将该片段放在安装检查器中,则需要该库的所有脚本都可以访问它?

Does it mean if I place that snippet in install checker, all scripts needing the library can access it?

如果没有,请让我知道在自制php.ini&中确切放置了什么.应该在哪个文件夹中.如果不行,我将使用.htaccess文件,则基于上述文件夹的确切内容应为&确切地说,它们应该在哪个文件夹中?我读到.htaccess文件应放在每个文件夹中.这是否真的意味着我应该在每个ZendGdata文件夹中放置一个文件夹?在无法在其他地方获得足够的答复之后,我希望能提供所有使我能够最终开始的指导,我将不胜感激.

If not, please let me know what exactly to place in the self-made php.ini & in which folder(s) it should be.Should that not work, and I were to use .htaccess files, what exactly, based on the folders mentioned above should be the content & exactly which folders should they be in? I read that the .htaccess files should be placed in each folder. Does it really mean I should place one in each of the ZendGdata folders?I would be grateful for any guidance enabling me to finally start, after failing to sufficient get responses elsewhere.

谢谢.

推荐答案

不必将所有ZendGdata代码放在您的网站文档根目录下.实际上,通常,我不要将PHP类库放置在可通过Web请求直接访问的位置,因为如果有任何方法可以通过直接调用类文件来作弊,那么任何人可以做到.

It's not necessary to put all the ZendGdata code under your website document root. In fact, as a rule I don't put PHP class libraries in a location that can be accessed directly by web requests, because if there's any way to do mischief by invoking the class files directly, then anyone can do it.

相反,将库放在文档根目录之外,然后从直接运行的脚本中引用它们.例如,您可以创建目录phplib作为public_html目录的姐妹.然后将ZendGdata捆绑包上传到该phplib目录下.

Instead, put libraries outside your document root and then reference them from scripts that are run directly. For example, you could create a directory phplib as a sister to your public_html directory. Then upload the ZendGdata bundle under that phplib directory.

您可以在.htaccess文件中设置PHP包含路径.您不需要在每个目录中都创建一个.htaccess文件,因为任何.htaccess文件中的指令都适用于.htaccess所在目录下的所有文件和目录.参见 http://httpd.apache.org/docs/2.2/howto/htaccess .html 了解更多信息.

You can set your PHP include path in a .htaccess file. You don't need to create a .htaccess file in every directory, because the directives in any .htaccess file apply to all files and directories under the directory where the .htaccess resides. See http://httpd.apache.org/docs/2.2/howto/htaccess.html for more information.

因此,我建议在/home/habaris6/public_html/site.root.folder中创建一个包含以下指令的.htaccess文件:

So I would recommend creating a .htaccess file at /home/habaris6/public_html/site.root.folder containing the following directives:

<IfModule mod_php5.c>
  php_value include_path ".:/usr/local/lib/php:/home/habaris6/phplib/ZendGdata/library"
</IfModule>

请参见 http://php.net/manual/en/configuration.changes. php 以获得更多信息.

See http://php.net/manual/en/configuration.changes.php for more info on this.

请注意,这假设您的网站托管公司允许您使用.htaccess文件,并且它们允许您在.htaccess文件中使用php_value指令.启用这些选项是一种Apache配置,出于性能或安全性的考虑,它们可以有自己的策略.您应该与他们联系以获得此答案.互联网上没有人可以回答有关您的托管服务提供商的政策的问题.

Note that this assumes your webhosting company allows you to use .htaccess files, and that they allow you to use the php_value directive in .htaccess files. Enabling these options is an Apache configuration and they could have their own policies against that for reasons of performance or security. You should contact them for this answer; no one on the internet can answer questions about your hosting provider's policies.

如果选择使用set_include_path() PHP函数将目录追加到运行时包含路径,则需要在用作Web请求着陆点的每个文件中执行此操作.也就是说,如果您允许直接向foo.php发出请求,则需要将代码添加到foo.php. foo.php随后包含的所有文件或类都使用您定义的包含路径.

If you choose to use the set_include_path() PHP function to append a directory to your runtime include path, you need to do this in each file that serves as a landing point for a web request. That is, if you permit a request to be made directly to foo.php then you need to add the code to foo.php. Any files or classes subsequently included by foo.php use the include path you defined.

还请注意,无论您使用什么方法定义包含路径,它都必须在脚本尝试通过包含路径加载任何PHP类文件之前生效. .htaccess方法应该可以完成此操作,如果您使用代码方法,则只需将代码放在PHP脚本中足够高的位置即可.

Note also that whatever method you use to define the include path, it has to take effect before your script tries to load any PHP class files via the include path. The .htaccess method should accomplish this, and if you use the code method you just have to put the code high enough in your PHP script.

我不使用在站点文档树中每个目录下创建自定义php.ini文件的方法.这是PHP 5.3.0的新功能,早期版本的PHP不支持.如果您使用的是Apache,则应仅使用.htaccess以获得相同的效果.

I don't use the method of creating a custom php.ini file under each directory within your site document tree. That's a new feature of PHP 5.3.0, not supported by earlier versions of PHP. If you're using Apache you should just use .htaccess for the same effect.

这篇关于Youtube API所需的设置Zend框架路径的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 02:35