3

I use composer to install Zend Framework 2 and other libraries. Every time after re-installing an application in the same path, I have to manually clear the APC (version 3.1.13) opcode cache (with PHP 5.4.8), otherwise I get errors like

PHP Fatal error:  Interface 'Zend\\Mvc\\ApplicationInterface' not found

or

PHP Fatal error:  include(): Cannot redeclare class zend\\eventmanager\\eventscapableinterface

The failing class keeps changing after every application install. I have apc.stat=1, so the opcode cache should notice newly deployed php files and recompile them automatically, if I have deployed the application on the same path before.

I have discussed the problem on Github with the composer developers and posted my APC settings here: https://github.com/composer/composer/issues/1662. We agree that this looks more like an APC problem.

aimfeld
  • 2,931
  • 7
  • 32
  • 43
  • I guess I could automatize APC opcode cache clearing using the somewhat complicated solution here: http://stackoverflow.com/a/3580939/94289. But I hope there's some easier fix. – aimfeld Mar 06 '13 at 11:03
  • 1
    `touch` all your updated files so they have a new timestamp, `apc` is pretty dumb. – Wrikken Mar 13 '13 at 21:57
  • I've seen somewhere on mailing list that there are problems with APC and PHP5.4, unfortunately I can't find it, to see what exactly was said. – Zdenek Machek Mar 13 '13 at 22:01
  • Does this question help at all? [PHP with APC: Fatal errors: Cannot redeclare class](http://stackoverflow.com/questions/4575341/php-with-apc-fatal-errors-cannot-redeclare-class) ... one suggestion is to try changing `apc.include_once_override = 0` – Simon Hampel Mar 14 '13 at 00:02
  • Thanks for the suggestions! @SimonHampel I already have `apc.include_once_override = 0`, see [here](https://github.com/composer/composer/issues/1662#issuecomment-14458750). @ZdenekMachek I'll try but since I delete the whole vendor folder (containing Zend Framework) upon reinstall and then install the contents again (from composer cache), I think the file timestamps should be updated automatically.. – aimfeld Mar 15 '13 at 08:37
  • @Wrikken: thanks, touching all files indeed fixes the problem: `find . -exec touch {} \;` If you like, provide this as an answer so I can accept and upvote it! – aimfeld Mar 15 '13 at 10:56

1 Answers1

0

I think that is include_path setted up twice. When include_path called twice it will make confusing to APC reading and parsing. Make sure that your ZEND project are not called twice on include_path.

And another checkout that you are properly configure ini settings or put manually ini settings data:

apc.include_once_override = 0
apc.canonicalize = 0
apc.stat = 0

In meanwhile this issue can be already solved due to updates.

Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53