使用 Zend Framework 的 WURFL 忽略缓存目录配置

发布于 2024-11-14 22:04:22 字数 1667 浏览 4 评论 0原文

我正在遵循有关使用 Zend Framework 设置 WURFL 的教程,以实现轻松的移动浏览器检测。

http:// /framework.zend.com/manual/en/zend.http.user-agent.html#zend.http.user-agent.quick-start

我已经将其设置为可以检测桌面浏览器并向我提供所有详细信息和功能该浏览器的,但是当我尝试使用 iPhone(移动 safari)访问该网站时,在尝试写入缓存目录时会抛出错误。

以下是我在错误日志中看到的内容:

2011-06-08T22:32:34-07:00 ERR (3): The file cache directory does not exist and could not be created. Please make sure the cache directory is writeable: /var/tmp

但是,在 /application/configs/wurfl-config.php 的配置中,我已将缓存目录设置为以下内容:

<?php
$resourcesDir            = dirname(__FILE__) . '/../../data/wurfl/';

$wurfl['main-file']      = $resourcesDir  . 'wurfl-2.0.27.zip';
$wurfl['patches']        = array($resourcesDir . 'web_browsers_patch.xml');

$persistence['provider'] = 'file';
$persistence['dir']      = $resourcesDir . '/cache/';

$cache['provider']       = null;

$configuration['wurfl']       = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache']       = $cache;

我还确保服务器可写它,但是 wurfl似乎认为我的缓存目录仍然是 /var/tmp

如何让 wurfl 观察我的缓存目录设置?

注释:本教程以wurfl-1.1为例,我只能在sourceforge上找到wurfl-1.3。这可能是一个问题。

注释:我的 application.ini 文件中有以下几行:

; WURFL
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.3.0/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"

I'm following the tutorial on setting up WURFL with Zend Framework to enable easy mobile browser detection.

http://framework.zend.com/manual/en/zend.http.user-agent.html#zend.http.user-agent.quick-start

I have got it setup to the point where it can detect a desktop browser and give me all the details and features of that browser, but when I try to access the website using an iPhone (mobile safari) it throws an error when trying to write to the cache directory.

Here's what I'm seeing in my error logs:

2011-06-08T22:32:34-07:00 ERR (3): The file cache directory does not exist and could not be created. Please make sure the cache directory is writeable: /var/tmp

However in my configuration at /application/configs/wurfl-config.php I have set the cache directory to the following:

<?php
$resourcesDir            = dirname(__FILE__) . '/../../data/wurfl/';

$wurfl['main-file']      = $resourcesDir  . 'wurfl-2.0.27.zip';
$wurfl['patches']        = array($resourcesDir . 'web_browsers_patch.xml');

$persistence['provider'] = 'file';
$persistence['dir']      = $resourcesDir . '/cache/';

$cache['provider']       = null;

$configuration['wurfl']       = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache']       = $cache;

I've also ensured it is writable by the server, but wurfl seems to think my cache directory is still /var/tmp

How can I get wurfl to observe my cache directory setting?

Notes: The tutorial uses wurfl-1.1 as the example, I have only been able to find wurfl-1.3 on sourceforge. This may be an issue.

Notes: I have these lines in my application.ini file:

; WURFL
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.3.0/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

独留℉清风醉 2024-11-21 22:04:22

不确定这是否是修复它的正确方法,但对我来说,问题是通过在 persistence.dir 键后添加额外的 .dir 解决的(使用 WURFL 1.3.0):

在 application.ini 中:(我不使用php 配置文件,因为如果我可以使用 .ini 指令,我不喜欢混合在 php 代码中)

resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir  = APPLICATION_PATH "/../data/wurfl/cache/"

所以我的 WURFL 完整配置在 Zend 的 application.ini 中看起来像这样:

; Mobile device detection
resources.useragent.storage.adapter             = "Session"
resources.useragent.wurflapi.wurfl_api_version  = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir      = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_array.wurfl.main-file      = APPLICATION_PATH "/../data/wurfl/wurfl.xml"
resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[]      = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
resources.useragent.wurflapi.wurfl_config_array.persistence.provider = "file"
resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir  = APPLICATION_PATH "/../data/wurfl/cache/"

可能是框架中关于如何读取配置的错误正在传递数组吗?

Not sure if this is the correct way to fix it, but for me the issue was solved by adding an extra .dir after the persistence.dir key (using WURFL 1.3.0):

In application.ini: (I don't use the php config file as I prefer not to mix in php code if I can use .ini directives)

resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir  = APPLICATION_PATH "/../data/wurfl/cache/"

So my complete config for WURFL looks like this in Zend's application.ini:

; Mobile device detection
resources.useragent.storage.adapter             = "Session"
resources.useragent.wurflapi.wurfl_api_version  = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir      = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_array.wurfl.main-file      = APPLICATION_PATH "/../data/wurfl/wurfl.xml"
resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[]      = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
resources.useragent.wurflapi.wurfl_config_array.persistence.provider = "file"
resources.useragent.wurflapi.wurfl_config_array.persistence.dir.dir  = APPLICATION_PATH "/../data/wurfl/cache/"

perhaps a bug in the framework regarding how it reads the config array it's being passed?

轻许诺言 2024-11-21 22:04:22

我刚刚解决了这个问题;)

从下面的代码行中删除 []

resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[]      = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"

将其转换为:

resources.useragent.wurflapi.wurfl_config_array.wurfl.patches = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"

I just resolved the problem ;)

remove the [] from the code line below:

resources.useragent.wurflapi.wurfl_config_array.wurfl.patches[]      = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"

transform it to:

resources.useragent.wurflapi.wurfl_config_array.wurfl.patches = APPLICATION_PATH "/../data/wurfl/web_browsers_patch.xml"
怕倦 2024-11-21 22:04:22

参数的格式似乎在版本 1.3 中发生了变化 - WURFL 文档 此处 有详细信息和示例文件。

因此,对于原来的问题, $persistence['dir'] 行需要更改为:

$persistence['params']   = array(
    'dir' => $resourcesDir . '/cache/'
);

It seems the format of the parameters has changed in version 1.3 - the WURFL docs here have the details and an example file.

So for the original question, the $persistence['dir'] line needs to be changed to:

$persistence['params']   = array(
    'dir' => $resourcesDir . '/cache/'
);
凶凌 2024-11-21 22:04:22

我使用 Wurfl 1.3.1 解决了问题并阅读了以下内容:

http://wurfl.sourceforge.net/nphp/< /a>

I solved the problem using Wurfl 1.3.1 and reading this:

http://wurfl.sourceforge.net/nphp/

趴在窗边数星星i 2024-11-21 22:04:22

关于 Jens Wegar 的上述回答,有一个错误修复请求来修复此问题,因为尚不清楚。

http://framework.zend.com/issues/browse/ZF-12284

With regards to Jens Wegar's answer above, there is a bug-fix request in to fix this as it's not clear.

http://framework.zend.com/issues/browse/ZF-12284

傻比既视感 2024-11-21 22:04:22

您是否将 UserAgent 资源配置为使用此处显示的设置?

您必须将resource.useragent.wurfl_* 条目添加到application.ini 文件中。

这是一个示例:

resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"

Did you configure the UserAgent resource to use the settings you are showing here?

You have to add resource.useragent.wurfl_* entries into your application.ini file.

Here is a sample:

resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文