0

Hi i try to add mobile template into current zend application but it return server error. Following are my configuration as i follow on several sites.

application.in

resources.frontController.plugins[] = "Rate_Application_Mobile"
resources.useragent.wurflapi.wurfl_api_version = "1.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl/WURFL/"
resources.useragent.wurflapi.wurfl_config_file = APPLICATION_PATH "/configs/wurfl-config.php"

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;

Mobile Plugin /var/www/library/Rate/Application/Mobile.php

class Rate_Application_Mobile extends Zend_Controller_Plugin_Abstract
{

    public function dispatchLoopStartup(Zend_Controller_Request_Abstract $req)
    {


        $front = Zend_Controller_Front::getInstance();
        $bootstrap = $front->getParam("bootstrap");

        $userAgent = $bootstrap->getResource('useragent');

        $device = $userAgent->getDevice();  --> this part return server error when switching to mobile browser, otherwise it return desktop when view as desktop browser


    }
}

Thanks!!

Update: Error return as follow

Warning: include(/var/www/library/wurfl/WURFL/Storage/.php): failed to open stream: No such file or directory in /var/www/library/wurfl/WURFL/ClassLoader.php on line 42

Warning: include(): Failed opening '/var/www/library/wurfl/WURFL/Storage/.php' for inclusion (include_path='/var/www/application/../library:/var/www/library:.:/usr/share/php:/usr/local/Zend/library') in /var/www/library/wurfl/WURFL/ClassLoader.php on line 42

Fatal error: Class 'WURFL_Storage_' not found in /var/www/library/wurfl/WURFL/Storage/Factory.php on line 43
Saraswathi Apavoo
  • 263
  • 2
  • 4
  • 18
  • What's exactly the error? – Tomasz Kowalczyk Feb 26 '13 at 02:09
  • it return server error – Saraswathi Apavoo Feb 26 '13 at 02:17
  • 1
    Yep, I did understand that, but does it return literal `server error` string or something more? No messages, codes, anything? Maybe some `error_reporting(E_ALL | E_STRICT);` at the top of the script will help? – Tomasz Kowalczyk Feb 26 '13 at 02:18
  • hi the above is the error it returns, i had no idea what it means since all files are in right place.. – Saraswathi Apavoo Feb 26 '13 at 02:25
  • 1
    This is PHP error stating that class file was not found. You're including empty name PHP file, so WURFL probably can't detect what it needs to load. Please do a `debug_backtrace()` before error line in `ClassLoader.php:42` (first error) and check what storage it tries / needs to load in `Factory.php:43`. If it's this file: https://github.com/knnktr-labs/wurfl/blob/master/WURFL/Storage/Factory.php you're trying to load a `file` provider which should be specified in `provider` config tree which you do provide, but it's not read. – Tomasz Kowalczyk Feb 26 '13 at 03:02
  • For now please clear ZF cache, and check if `$persistence['provider'] = 'file';`, `$cache['provider'] = null;` and `$configuration['persistence'] = $persistence;` do not interfere. – Tomasz Kowalczyk Feb 26 '13 at 03:05
  • Great it works, now how can redirect from default module to mobile module? I have a module for mobile – Saraswathi Apavoo Feb 26 '13 at 03:28
  • Simply check what WURFL is expected to return on mobile and desktop, and act accordingly (switch templates or something). See this: http://stackoverflow.com/questions/2630180/how-to-detect-desktop-browser-vs-mobile-device-using-wurfl . Also, please upvote and accept my answer :) – Tomasz Kowalczyk Feb 26 '13 at 03:33

1 Answers1

0

This is an answer I gave in the comments above, copied and pasted just for the sake of upvoting and accepting.

This is PHP error stating that class file was not found. You're including empty name PHP file, so WURFL probably can't detect what it needs to load. Please do a debug_backtrace() before error line in ClassLoader.php:42 (first error) and check what storage it tries / needs to load in Factory.php:43. If it's this file: Factory.php you're trying to load a file provider which should be specified in provider config tree which you do provide, but it's not read.

For now please clear ZF cache, and check if

$persistence['provider'] = 'file';
$cache['provider'] = null;
$configuration['persistence'] = $persistence; 

do not interfere.

Tomasz Kowalczyk
  • 10,472
  • 6
  • 52
  • 68