We had the same problem over here. Here's the story and how we fixed it.
On our machine, we were trying to get PHP 5.6 running and wanted to compile the PHP extension for couchbase against it. We also had PHP 7.1 and PHP 7.0 installed on the same machine. PECL put the compiled file into /usr/lib/php/20151012/couchbase.so
, which wasn't inside the path defined in extension_dir
, so we had to set it absolutely in order to load it in PHP 5.6 and got an error, similar to yours ... What we noticed later is, that the name of the folder 20151012
represents the PHP API version, which usually changes with each PHP version. Since we anyways didn't use the later PHP version, we just removed PHP 7.1 and 7.0 and tried again. Now it correctly compiled against PHP 5.6, saved the so-file to /usr/lib/php/20131226/couchbase.so
and we could use it.
Long story short:
When compiling an extension, PECL puts it into a folder like /usr/lib/php/20131226
. The last folder-name represents the PHP API this extension is compiled against. Please check your version by calling php -i | grep 'PHP API'
and see if these numbers match.
If you also have multiple PHP versions installed and want to keep them, this answer might be helpful: pecl installs for previous php version
A helpful tip
PHP has a variable called extension_dir
which is a prefix for all paths to extensions loaded using a relative path. If you load modules just by setting the filename (and let PHP add the prefix), you should not have these issues. Be aware of that you have to use absolute paths for extensions loaded as zend_extension
- as f.e. xdebug ...