Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZF classes declared twice when calling piwik api from a ZF project #631

Closed
anonymous-matomo-user opened this issue Mar 26, 2009 · 7 comments
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@anonymous-matomo-user
Copy link

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](http://dev.piwik.org/trac/wiki/API/CallingTechniques) 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
Copy link
Contributor

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

@robocoder
Copy link
Contributor

Or perhaps add a ZF_INCLUDE_PATH if defined?

@mattab
Copy link
Member

mattab commented Apr 27, 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
Copy link
Contributor

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

@robocoder
Copy link
Contributor

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

@robocoder
Copy link
Contributor

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

@robocoder
Copy link
Contributor

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

@anonymous-matomo-user anonymous-matomo-user added this to the Piwik 0.4 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

3 participants