@anonymous-piwik-user opened this issue on March 26th 2009

i have tried to use piwik in a zend framework project so i have copy the example on the Calling the API From within PHP page and paste it in a zf controller and got the error "cannot redeclare class Zend_Exception"

this happen very early in the process :

index.php l 45 : require_once "FrontController.php";

i think the easiest way to solve it is to change the set_include_path argument with get_include_path() in first position so if zend lib is already used the files will be included from there but : 1) it will slow down every other inlusion adding folders to look in at the top of the stack

2) maybe some compatibility pb can happen between piwik version and the user version (users need to have up piwik version of zf or later to ensure full compat, except if major breaking changes are introduced into zf but that seems unlikely)

At first i tough about a config entry like 'overwrite ZF Folder = my/folder/to/ZF' but when the error occur there is no access to the config file yet ...

PS : maybe same pb can happen with other third party librarys (smarty is used a lot too ...)

@robocoder commented on April 25th 2009

I propose that get_include_path only come first if PIWIK_INCLUDE_PATH is already defined.

@robocoder commented on April 25th 2009

Or perhaps add a ZF_INCLUDE_PATH if defined?

@mattab commented on April 27th 2009

I would say that when using piwik inside a ZF project, piwik should use the ZF classes already included, and should not use the piwik/libs/Zend/* classes. Most likely when we do the update of all zend framework classes (#497) which shouldn't be too much work, any project using piwik would use a recent enough version of ZF to not have any compatibility issue.

A proper fix to this ticket would actually to autoload all zend classes (information in #620) so that autoload would detect that the classes are already loaded and not try to include the files.

@robocoder commented on May 22nd 2009

re: tom67's comment re: smarty: shouldn't be a concern following [1142]

@robocoder commented on May 26th 2009

When Piwik is called from within a ZF project, Piwik should act like a library and not set the include path.

@robocoder commented on May 26th 2009

(In [1146]) fixes #631 - make set_include_path() conditional on presence of Zend/Version.php

@robocoder commented on May 28th 2009

(In [1150]) fixes #743 - optimize include path; refs #631

This issue was closed on August 13th 2009
Powered by GitHub Issue Mirror