how to use phpexcel in zend framework - zend-framework

I need to import data from excel,And the I decided to use PHPExcel,But when I require it in my web , a few warnings occured :
Warning:
include_once(PHPExcel\Shared\ZipStreamWrapper.php) [<a href='function.include-once'>function.include-once</a>]:
failed to open stream: No such file or directory in D:\www\LearningCenter\library\Zend\Loader.php on line 146
here is my code.:
public function getUserFromExcel($path){
echo $path;
require_once 'Excel/PHPExcel.php';
echo $path;
}
and my webapp structre is :
library
Zend
Excel
others-thirdpart-library
it seems that there is something wrong with the autoloader.
I read a few articles But did not find a solution.
My final aim is to read date from an excel file:
can some one give me some sugestion on ether how to use phpexcel in zend or how to import data from excel useing zend itself.
thanks

copy the PHPExcel library into your /library directory, the structure should be as follows
/library
/PHPExcel
/PHPExcel.php
and then add this in your application.ini
autoloaderNamespaces[] = "PHPExcel_"
autoloaderNamespaces[] = "PHPExcel"
and it should work.

Add your lib to library folder. (libarary/PHPExcel)
Add new autoloaderNamespaces.phpexcel = "PHPExcel_"
You can use library method using PHPExcel_IOFactory::createReader($inputFileType);

The problem is related to autoload PHPExcel classes.
I suggest to avoid to have problems with autoload PHPExcel classes to use the zf2 module MvlabsPHPExcel that will give you an easy integration of [PHPOffice/PHPExcel][2] library into zend framework 2.

Related

Zend-framework Loading mpdf in a Project

I have a project in zend 1.12 and I tried to use composer and then use mpdf, but it did not work, as it always goes to controller, and I am new to Zend-framework.
[09-Feb-2017 00:32:28 Europe/Kiev] PHP Warning: require_once(C:\wamp\www\Avala\application\controllers/vendor/autoload.php): failed to open stream: No such file or directory in C:\wamp\www\Avala\application\controllers\PdfCreatorController.php on line 30
I got it. Just copy mpdf folder inside library/ of zend 1 and then call it as
//loading mpdf class from library
requre_once 'mpdf/mpdf.php';
//call instance of mpdf
$pdf = new mPDF('utf-8', 'A4-L'); // New PDF object with encoding & page size
then its work. do not need any other settings

DomPDF not working in Zend Framework 1.12.0 An input file is required (i.e. input_file _GET variable)

DomPDF throws the following error, using Zend Framework 1.12.0.
Error
An input file is required (i.e. input_file _GET variable).
However, it works fine using Zend 1.7.0.
Here is the way I've included it in the controller
require_once("dompdf_config.inc.php");
spl_autoload_register('DOMPDF_autoload');
And this is how I instantiate Zend Loader Autoloader in my Bootstrap file
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
I believe it may be due to autoloading DOMPDF. Any suggestions?

Not able to register Plugin in Zend Framework application.ini

my plugins directory sits in
application
/plugins
Dbcount.php
ModuleLayout.php
i am unable to register the plugin with frontController. here is my application.ini code.
#Plugin path and namespace
pluginPaths.Plugins = APPLICATION_PATH "/plugins"
autoloaderNamespaces[] = "Plugin_"
#register plugin
resources.frontController.plugins[] = "Plugin_DbCount"
it gives me following error.
Warning: include_once(Plugin/DbCount.php) [function.include-once]: failed to open stream: No such file or directory in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Loader.php on line 146
Warning: include_once() [function.include]: Failed opening 'Plugin/DbCount.php' for inclusion (include_path='/Users/azhararmar/htdocs/joofris/v1/application/../library:/Users/azhararmar/htdocs/joofris/v1/library:.:/Applications/MAMP/bin/php5.2/lib/php') in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Loader.php on line 146
Fatal error: Class 'Plugin_DbCount' not found in /Users/azhararmar/htdocs/joofris/v1/library/Zend/Application/Resource/Frontcontroller.php on line 117
what is wrong?
If you are using the default appnamespace Application, then the plugin stored in application/plugins/DbCount.php should be named Application_Plugin_DbCount. Use the full classname when you register:
resources.frontController.plugins[] = "Application_Plugin_DbCount"
To use the namespace like that your Plugin classes need to be under Library or you need to map them else where. Looks like you have the frontcontroller plugin set up right but incorrect autoload definitions.
Easiest thing to do here is to name your plugins YourAppNamespace_Plugin_YourPluginName.
They are two types of plugin in ZF . You are mixing some part of each .
To make your code work do
1) put application dir in include_path
2) change directory name plugins to 'Plugin'

Exception while setting up the wurfl in zend

I have includes all the parameters using the article at http://framework.zend.com/manual/en/zend.http.user-agent.html#zend.http.user-agent.quick-start
but it shows me an exception Unable to resolve plugin "useragent"; no corresponding plugin with that name. My code is :
all configuration in application.ini
resources.useragent.storage.adapter = "Session"
resources.useragent.wurflapi.wurfl_api_version = "1.3.1"
resources.useragent.wurflapi.wurfl_lib_dir = APPLICATION_PATH "/../library/wurfl-php-1.3.1/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/"
loaded the files at downloaded from http://sourceforge.net/projects/wurfl/files/WURFL%20PHP/1.1/wurfl-php-1.1.tar.gz/download
version 1.3.1
Root_DIR/library/wurfl-php-1.3.1
and created data folder with application and updated with Root_DIR/data/wurfl
/chache
web_browsers_patch.xml
wurfl.xml
What is i am mising ?? Thanks in advance.
It was due to version problem. i resolved it after updating version of zend library. it supports on zend V 1.11 and above. and after this successful implementation still i am getting an exception like :
Strict Standards: Declaration of Application_Helper_MobileContext::addActionContext() should be compatible with that of Zend_Controller_Action_Helper_ContextSwitch::addActionContext() in /storage/projects/gomotive/application/helpers/MobileContext.php on line 3
But also resolved this by passing default argument value in parent method. check the link below
Declaration of Methods should be Compatible with Parent Methods in PHP
Hi the solutions is include Zend framework into your library folder.I am facing the same problems and by accidentally i include the Zend Framework v1.11 into library and all works well

generate-migrations-diff failing with Zend framework

I am trying to generate a migration script using Doctrine with Zend Framework. I am getting the following:
$ php doctrine.php generate-migrations-diff
$ PHP Fatal error: Cannot redeclare class Avo_Model_AccessType in
$ tmp/fromprfx_doctrine_tmp_dirs/AccessType.php on line 16
I can successfully build the models form the yaml file. I am using Zend Framework 1.10.5 and Doctrine 1.2.2 I think the issue might be with the autoloader and the fact that Zend Autoloads the classes that doctrine is trying to re-create.
I've got the same error today. The problem was that in bootstrap I preloaded all models with
Doctrine_Core::loadModels($options['models_path']);
So, I just removed that line and it helped.