There is no device with ID Using Zend and WURFL - zend-framework

I have integrate WURFL 1.6.0 with Zend every thing goes smooth it detects the desktop but in case of Android i am getting this error .On digging in deep i found out that my dir data/wurfl/cache is not loading with any data i have given it 777 permission but still it didnt work.
[25-Jun-2015 09:39:09] PHP Fatal error:
Uncaught exception 'Exception' with message 'There is no device with ID [generic_android_ver4_4] in the loaded WURFL Data' in /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php:108
Stack trace:
#0 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php(211): WURFL_CustomDeviceRepository->getDevice('generic_android...')
#1 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLService.php(146): WURFL_CustomDeviceRepository->getDeviceHierarchy('generic_android...')
#2 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLService.php(62): WURFL_WURFLService->getWrappedDevice('generic_android...', Object(WURFL_Request_GenericRequest))
#3 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/WURFLManager.php(90): WURFL_WURFLService->getDeviceForRequest(Object(WURFL_Request_GenericRequest))
#4 /var/www/vhosts/mobiletocash.co.uk/httpdocs/library in /var/www/vhosts/mobiletocash.co.uk/httpdocs/library/wurfl-php-1.6.0.1/WURFL/CustomDeviceRepository.php on line 108
$resourcesDir = dirname(__FILE__) . '/../../data/wurfl/';
$wurfl['main-file'] = $resourcesDir . 'wurfl.xml';
$wurfl['patches'] = array($resourcesDir . 'web_browsers_patch.xml');
$cache['provider'] = 'Null';
//
$persistence['provider'] = 'File';
$persistence['dir'] = $resourcesDir . '/cache/';
$configuration['wurfl'] = $wurfl;
$configuration['persistence'] = $persistence;
$configuration['cache'] = $cache;
if i give $cache['provider'] = null;
it throws another exception . tried using $persistence['provider'] = 'file'; but no use

From what I can tell it does not look like the WURFL file is being properly loaded (perhaps the directory is not writeable) or is out of date. You most likely need to delete the persistence directory and reload the WURFL API.

Related

I keep getting this error on Slim 4 after installing new version 4.12

I keep getting this error Slim Application Error after installing the new Slim 4 framework.
I tried switching back to old version of slim but I keep getting the same thing.
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
/**
* Instantiate App
*
* In order for the factory to work you need to ensure you have installed
* a supported PSR-7 implementation of your choice e.g.: Slim PSR-7 and a supported
* ServerRequest creator (included with Slim PSR-7)
*/
$app = AppFactory::create();
// Add Routing Middleware
$app->addRoutingMiddleware();
/*
* Add Error Handling Middleware
*
* #param bool $displayErrorDetails -> Should be set to false in production
* #param bool $logErrors -> Parameter is passed to the default ErrorHandler
* #param bool $logErrorDetails -> Display error details in error log
* which can be replaced by a callable of your choice.
* Note: This middleware should be added last. It will not handle any exceptions/errors
* for middleware added after it.
*/
$errorMiddleware = $app->addErrorMiddleware(true, true, true);
// Define app routes
$app->get('/hello/{name}', function (Request $request, Response $response, $args) {
$name = $args['name'];
$response->getBody()->write("Hello, $name");
return $response;
});
// Run app
$app->run();
Output:
Slim Application Error
The application could not run because of the following error:
Details
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Line: 91
Trace:
#0 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php(57): Slim\Middleware\RoutingMiddleware->performRouting(Object(Slim\Psr7\Request))
#1 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Slim\Middleware\RoutingMiddleware->process(Object(Slim\Psr7\Request), Object(Slim\Routing\RouteRunner))
#2 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/Middleware/ErrorMiddleware.php(89): class#anonymous->handle(Object(Slim\Psr7\Request))
#3 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(132): Slim\Middleware\ErrorMiddleware->process(Object(Slim\Psr7\Request), Object(class#anonymous))
#4 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/MiddlewareDispatcher.php(73): class#anonymous->handle(Object(Slim\Psr7\Request))
#5 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/App.php(206): Slim\MiddlewareDispatcher->handle(Object(Slim\Psr7\Request))
#6 /opt/lampp/htdocs/MyocappAPI/vendor/slim/slim/Slim/App.php(190): Slim\App->handle(Object(Slim\Psr7\Request))
#7 /opt/lampp/htdocs/MyocappAPI/public/index.php(41): Slim\App->run()
#8 {main}
I'm glad OP figured it out, but he didn't share his solution so here is what worked for me:
$app = AppFactory::create();
$app->setBasePath("/slimapp/public/index.php");
where the full path to my starter page is:
C:\xampp\htdocs\slimapp\public\index.php
To test my starter page, the URL I used was:
localhost/slimapp/public/index.php/hello/Beautiful
I think in Slim 3 you didn't need to manually set the base path, but you do in Slim 4. I don't know if it's a bug but this worked.
Slim 4 has some bugs in routing. So,Downgrade the slim version to 3.*
Reference:
https://discourse.slimframework.com/t/slim-4-httpnotfoundexception/3273/18

Extbase can't use external PHP library

I am building a simple extension to display information on a Google Maps with Typo3.
I want to use the following PHP class (http://www.ycerdan.fr/developpement/google-maps-api-v3/) but I can't use it in my Controller.
I tried to use autoloading and require_once in my controller, but I just get PHP or Typo3 errors.
I guess it's a trivial problem, but I can't make it work despite lot of time searching.
Any help or hint are greatly appreciated ;)
General infos
Vendor name : CLICmap
Extension name : clicmap
Class location : Resources/Private/PHP
ext_autoloader.php :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
return array(
'gmaps' => $extensionPath.'Resources/Private/PHP/GoogleMapAPIv3.class.php',
);
How I use it in my controller
public function listAction() {
$maps = $this->mapRepository->findAll();
$gmaps = $this->objectManager->get('gmaps');
$this->view->assign('maps', $maps);
}
The PHP error :
Uncaught TYPO3 Exception
#1289386765: Could not analyse class:gmaps maybe not loaded or no autoloader? (More information)
TYPO3\CMS\Extbase\Object\Container\Exception\UnknownObjectException thrown in file
/var/www/html/ftypo3/typo3/sysext/extbase/Classes/Object/Container/ClassInfoFactory.php in line 37.
Trying require_once :
$extensionPath = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('clicmap');
require_once($extensionPath . 'Ressources/Private/PHP/GoogleMapAPIv3.class.php');
I get the following PHP error :
Warning: Uncaught exception 'TYPO3\CMS\Core\Error\Exception' with message 'PHP Warning: require_once(/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php): failed to open stream: No such file or directory in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php line 52' in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php:101 Stack trace: #0 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): TYPO3\CMS\Core\Error\ErrorHandler->handleError(2, 'require_once(/v...', '/var/www/html/f...', 52, Array) #1 /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php(52): CLICmap\Clicmap\Controller\MapController::listAction() #2 [internal function]: CLICmap\Clicmap\Controller\MapController->listAction() #3 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php(286): call_user_func_array(Array, Array) #4 /var/www/html/ftypo3/typo3/sysext/extbase/Classes/Mvc/ in /var/www/html/ftypo3/typo3/sysext/core/Classes/Error/ErrorHandler.php on line 101
Fatal error: CLICmap\Clicmap\Controller\MapController::listAction(): Failed opening required '/var/www/html/ftypo3-fluid/typo3conf/ext/clicmap/Ressources/Private/PHP/GoogleMapAPIv3.class.php' (include_path='/var/www/html/ftypo3-fluid/typo3/contrib/pear/:.:/usr/share/php:/usr/share/pear') in /var/www/html/ftypo3/typo3conf/ext/clicmap/Classes/Controller/MapController.php on line 52
EDIT : Solved
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.
The code that solved my problem in the controller :
require_once(PATH_site . 'typo3conf/ext/clicmap/Resources/Private/PHP/GoogleMapAPIv3.class.php');//OK
$gmap = new \GoogleMapAPI();
I was messing with the filepath and most importantly i hadn't put a \ before my class instanciation.

imagick error: 'unable to open image' image upload

I get the following error when trying to process uploaded images with imagick.
Fatal error: Uncaught exception 'ImagickException' with message 'unable to open image `9eK59iu.jpg': No such file or directory # error/blob.c/OpenBlob/2644' in D:\PATH\upload.php on line 77
The code looks like this:
<?php
$new_folder_name = "D:/PATH/content";
mkdir("$new_folder_name",0700);
$tmp_img = $_FILES["upload_file"]["tmp_name"];
$img = new Imagick($tmp_img);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
Without imagick the image upload works just fine.
Only imagick won't open the image given to $_FILES
I also tried to open the image with imagick, after move_uploaded_file, like this:
<?php
$extension = pathinfo($upload_file_name, PATHINFO_EXTENSION);
$new_upload_file_name = rand(00000, 99999).".".$extension;
$new_folder_name = "D:/PATH/content".time();
mkdir("$new_folder_name",0700);
$path_to_file = $new_folder_name."/".$new_upload_file_name;
move_uploaded_file($_FILES["upload_file"]["tmp_name"],$path_to_file);
$img = new Imagick($path_to_file);
$img->thumbnailImage(100 , 100 , TRUE);
$img->writeImage($new_folder_name);
?>
neither works.. :-(
Any suggestion?
Read the file upload docs. The server-side temporary filename assigned by PHP to store the uploaded file in ['tmp_name'] in the $_FILES array. You're trying to use the client-side user-provided ['name'], which DOES NOT exist anywhere on your server.
$tmp_img = $_FILES["upload_file"]["tmp_name"];
^^^^
You are also simply assuming that the upload has succeed. That is NOT a good thing. Never EVER assume success with dealing with remote resources (web apis, file uploads, database operations, etc...). ALWAYS check for errors:
if ($_FILES['upload_file']['error'] !== UPLOAD_ERR_OK) {
die("Upload failed with error code " . $_FILES['upload_file']['error']);
}

Google authentication

I got a problem on google authenticate, it worked for a month but since a few days I got this error :
Fatal error: Uncaught exception 'apiAuthException' with message
'Invalid token format' in /home/project/html/google/auth/apiOAuth2.php:127 Stack trace:
#0 /home/project/html/google/auth/apiOAuth2.php(89): apiOAuth2->setAccessToken('{? "access_tok...')
#1 /home/project/html/google/apiClient.php(132): apiOAuth2->authenticate(Array)
#2 /home/project/html/hk/connects/google.php(22): apiClient->authenticate()
#3 {main} thrown in /home/project/html/google/auth/apiOAuth2.php on line 127
In apiOAuth2.php I have the code :
$accessToken = json_decode($accessToken, true);
if (! isset($accessToken['access_token']) || ! isset($accessToken['expires_in']) || ! isset($accessToken['refresh_token'])) {
throw new apiAuthException("Invalid token format");
}
I noticed that google doesn't send me the $accessToken['refresh_token'].
It doesn't seem to come from google cause I did a correct connexion on http://stackoverflow.com
Maybe it's cause of my code :
session_start();
$client = new apiClient();
$plus = new apiPlusService($client);
if (!isset($_GET['code'])) {
header('Location: '.$client->createAuthUrl()); // Calls the same page
} else {
$client->authenticate(); // Fails at this level
}
EDIT:
I figured a way to do it, like I don't know what is refresh_token made for I added this line :
if (!isset($accessToken['refresh_token'])) $accessToken['refresh_token'] = 12345678910;
It works for the moment...
There is a new explicit parameter called "access_type" required by the google authentication api to obtain a valid refresh token.
With this parameter you declare that you need offline access to the account and the api provides you a refresh token.
Download the latest google PHP SDK that automatically handles the new required parameter

Zend Framework : Invalid contrller specified (error) ??? Help

I moved my project from windows to ubuntu and had this error while trying to run the project:
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with
message 'Invalid controller specified (error)' in
/home/truong/webdev/qtcmsv2/library/Zend/Controller/Dispatcher/Standard.php:248
Stack trace:
#0 /home/truong/webdev/qtcmsv2/library/Zend/Controller/Front.php(954):
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http))
#1 /home/truong/webdev/qtcmsv2/library/Zend/Application/Bootstrap/Bootstrap.php(97):
Zend_Controller_Front->dispatch()
#2 /home/truong/webdev/qtcmsv2/library/Zend/Application.php(366):
Zend_Application_Bootstrap_Bootstrap->run()
#3 /home/truong/webdev/qtcmsv2/index.php(56):
Zend_Application->run()
#4 {main} thrown in
/home/truong/webdev/qtcmsv2/library/Zend/Controller/Dispatcher/Standard.php
on line 248
I did have ErrorController.php file in my default module :
class ErrorController extends Zend_Controller_Action {
/**
* This action handles
* - Application errors
* - Errors in the controller chain arising from missing
* controller classes and/or action methods
*/
public function errorAction()
{
$errors = $this->_getParam('error_handler');
switch ($errors->type) {
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
// 404 error -- controller or action not found
$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
$this->view->title = 'HTTP/1.1 404 Not Found';
break;
default:
// application error; display error page, but don't change
// status code
$this->view->title = 'Application Error';
break;
}
$this->view->message = $errors->exception;
}
}
My project ran very smoothly in Windows, but the error above always occurs when running in Ubuntu.
How can I solve this problem?? Please help me!
ps : Sorry for my bad English.
Means ZF can't find the error controller so it could be that something is not where it belongs, something is configured incorrectly (like a path), is misnamed, permissions are off, etc. Hard to tell from the info you provided as the error could be in index.php, your bootstrap, config, etc.