Class 'PharData' not found - php

I get this error on my production server (CentOS 5.4 and php 5.3.5) :
Warning: include_once(PharData.php): failed to open stream: No such
file or directory in /var/www/ZendFramework/library/Zend/Loader.php on
line 146
Warning: include_once(): Failed opening 'PharData.php' for inclusion
(include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php')
in /var/www/ZendFw/library/Zend/Loader.php on line 146
Fatal error: Class 'PharData' not found in
/var/www/vm/app/Backup.php on line 40
And this is the code which fail :
$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");
This code is working fine on my own computer.
PharData should be included by default in php 5.3+ ...
Thanks for your help!
UPDATE :
I am using the Zend Auto loader feature to load the good php files using this code :
require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
Zend autoloader is doing the include_once(PharData.php).

Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.
To confirm this, run the following script:
<?php
phpinfo();
?>
One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.
If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).

Related

App Engine PHP - cant find curl.so

Run dev_appserver.py and now get an error relating to curl.so:
PHP Warning: PHP Startup: Unable to load dynamic library 'C:\dev\google-cloud-sdk\platform\google_appengine\php\php-5.5-Win32-VC11-x86\curl.so' - The specified module could not be found.
This file does appear to be missing from the directory specified but haven't touched anything and have not had this error before.
How do I resolve?
Additional info
I have found there is already a php.ini file in same directory as app.yaml, just a few basic lines:
extension = "curl.so"
;extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
So I changed it to comment out the first line and restore the second line:
;extension = "curl.so"
extension=C:\dev\xampp\php\ext\php_curl.dll
;extension=C:\dev\xampp\php\ext\php_mysqli.dll
The error now changes to cant find ...php_curl.dll.
Yet the file seems to be there:
So why the error now? seems the path to dll is correct.
If you want to use Curl and not Curl Lite, then you need to reference the .dll version while using a Windows based system. Create a php.ini file in the same directory as your app.yaml file add the following line to it:
extension = php_curl.dll
If instead you want to use curl lite, you can remove the line above and instead add:
google_app_engine.enable_curl_lite = "1"
to the php.ini file.

cURL 7.27.0-1 fails to load via Apache PHP, but works great on php command line

We have an intranet site that has multiple PHP scripts which start using curl_init(). The other day there was an update for ArchLinux which messed with some of the dependencies of cURL (glibc). This caused the curl module to not properly load in PHP, that is, extension_loaded('curl') fails.
I get this error from Apache /var/http/error_log:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/lib/php/modules/curl.so' - /lib/libc.so.6: version `GLIBC_2.16'
not found (required by /usr/lib/libcurl.so.4) in Unknown on line 0
The weird thing is we have another nearly identical script (on the same machine) that runs on PHP command line using curl_init() that runs via a cron job and PHP loads cURL properly during the execution of this script. That works perfectly fine.
cURL is configured to run in php.ini via extension=curl.so
If I check phpinfo(), I see '--with-curl=shared'. However it does not show the cURL info table. This tells me that the module isn't loading properly.
The curl.so file is in place at: /usr/lib/php/modules/curl.so
These cURL scripts also normally function properly, they are currently working great on another test machine.
This issue occurs on PHP 5.4.5
ldd /usr/lib/libcurl.so.4
linux-gate.so.1 (0xb7770000)
libssh2.so.1 => /lib/libssh2.so.1 (0xb76de000)
librt.so.1 => /lib/librt.so.1 (0xb76d5000)
libssl.so.1.0.0 => /lib/libssl.so.1.0.0 (0xb7673000)
libcrypto.so.1.0.0 => /lib/libcrypto.so.1.0.0 (0xb74ad000)
libz.so.1 => /lib/libz.so.1 (0xb7495000)
libpthread.so.0 => /lib/libpthread.so.0 (0xb747a000)
libc.so.6 => /lib/libc.so.6 (0xb72d4000)
libdl.so.2 => /lib/libdl.so.2 (0xb72cf000)
/lib/ld-linux.so.2 (0xb7771000)
In my distro, the change they made was that /lib is now a symlink to /usr/lib: http://www.archlinux.org/news/the-lib-directory-becomes-a-symlink/
EDIT
I tried what DaveRandom suggested here...
[root http]# php -r " echo (file_exists('/usr/lib/php/modules/curl.so')) ? 'It exists.' : 'It doesn\'t e.'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: file_exists(): open_basedir restriction in effect. File(/usr/lib/php/modules/curl.so) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in Command line code on line 1
Warning: file_exists(): open_basedir restriction in effect. File(/usr/lib/php/modules/curl.so) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/) in Command line code on line 1
It doesn't exist.
It failed because it didn't allow access to that path via the ini, so I reconfigured it and tried again...
[root http]# php -r " echo (file_exists('/usr/lib/php/modules/curl.so')) ? 'It exists.' : 'It doesn\'t exist.'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
It exists.
Freaky thing though is that JSON is actually working...
[root m]# php -r " echo (extension_loaded('json')) ? 'It is loaded' : 'It is not loaded'; "
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/modules/json.so' - /usr/lib/php/modules/json.so: cannot open shared object file: No such file or directory in Unknown on line 0
It is loaded
I guess the question is, what would cause cURL to work on command line, the module file to be there, but fail to load the extension via Apache PHP.
Then on the other hand what would cause JSON to give a warning, but still actually load?
Anybody know what the heck this could be?
Thanks
Alrighty, I found a work around. It's basically just to downgrade from cURL 7.27.0-1 to 7.26.0-1, which kind of sux, but it works:
I think this issue was unique to ArchLinux, but this will fix it (if you're an ArchLinux user like me).
mkdir /tmp/pacman_build
cd /tmp/pacman_build
cp /var/cache/pacman/pkg/curl-7.26.0-1-`uname -m`.pkg.tar.xz .
tar -xJf curl-7.26.0-1-`uname -m`.pkg.tar.xz
LD_PRELOAD=/tmp/pacman_build/usr/lib/libcurl.so pacman -U /var/cache/pacman/pkg/curl-7.26.0-1-`uname -m`.pkg.tar.xz
Please note, this requires you to recently have version 7.26.0-1 of curl in your package manager cache. If this fails, check /var/cache/pacman/pkg for another version of curl. If you don't have one in there, you'll have to find one.

Install ingres extension for php on my WAMP server

I've a development computer, which runs under windows.
For a project, I've to make a php website which has to connect to an Ingres database server.
So I installed wamp, I installed ingres(server and client, on my local machine).
I added the library that I found on their site(php_ingres.dll) in the C:\wamp\bin\php\php5.3.5\ext folder, and I added a line "extension=php_ingres.dll" in the configuration file.
I shutdown wamp and restarted it, and I restarted the server, I see now a check mark in the wamp menu, indicating that php_ingres is now activated. But when I go to the welcome page of the server, I don't see this extension as loaded. If I go on the php info page, I don't see any Ingres entry in the Configure Command.
I just can't found any post/tutorial/... which indicating how to do this operation, so any help would be appreciated!
Thank you!
Edit: I made a small test to see if I can connect to an Ingres database:
<?php
$link = ingres_connect("localhost", "demodbtest", "demodbtest") or die("Connexion impossible");
echo "Connexion réussie";
$result = ingres_query($link,"select * from airline");
while ($row = ingres_fetch_array($result)) {
echo $row["al_iatacode"]; // utilisation du tableau associatif
echo $row["al_name"];
echo $row["al_ccode"]; // utilisation du tableau à indices numériques
echo "</br>";
}
ingres_close($link);
?>
And I get this error:
( ! ) Fatal error: Call to undefined function ingres_connect() in
C:\wamp\www\tests\index.php on line 2
Some information on my installation:
I've a windows 7 pro 32bits
Wampserver 2.1 ( http://sourceforge.net/projects/wampserver/files/WampServer%202/WampServer%202.1/WampServer2.1e-x32.exe/download )
Apache 2.2.17
PHP 5.3.5
Ingres 10.1.0 Community edition( downloaded here: http://esd.ingres.com/product/Community_Projects/Ingres_Database/Windows_32-Bit/Ingres_10.1_Build_121/ingres-10.1.0-121-gpl-win-x86-NoDoc.zip/http )
PHP drivers downloaded here: http://esd.ingres.com/product/drivers/PHP/Windows_32-Bit/PHP_Driver
To practically test if the extension was loaded you can as well call one of it's functions. If the extension was loaded, you should not get a fatal error for a missing function. That's perhaps one of the quickest checks.
Another check is to make use of extension_loaded *PHP Manual** which will give you a list of all loaded extensions. See the PHP Manual link above for more info.
The configure line
The configure line will not show the ingres extension because it has not been compiled in. That's perfectly alright because you load it as an extension (.dll) so it's not part of php.exe. This is why you don't see it in the configure line.
Locating ingres on the phpinfo() page.
On the phpinfo()-page use the search function inside your browser (often CTRL+F) and try to locate the word ingres. You should locate a section that displays the extensions default settings if it has been loaded.
The following is an example screenshot for the xdebug extension. This might look similar for ingres:
Image from: Launching xdebug in Eclipse stuck at 57% - How to trouble-shoot?
Double check your extension_dir setting as well as the actual php.ini file being used. Calling php.exe -i from the command line might not give the same output if executing phpinfo() in a script via Apache (or IIS). In fact http://www.wampserver.com/en/faq.php says there are 3 potential php.ini scripts.
The problem is that I wasn't having the ingres client installed locally, so it appears that this lib cannot works without it

PHP Extension (memcache|memcached) not showing in phpinfo() but showing in php -m and php -i?

I am getting both modules listed as installed / configured when I use:
php -m
or if I use:
php -i
but when I use:
$m = new Memcache;
// or
$m = new Memcache();
// or
$m = new Memcached();
//or
$m = new Memcached;
I get the following error:
Fatal error: Class 'Memcached' not found
I am running on a Mac - OS X (10.5.7) with default install of apache & php. Additionally, I have memcached running as a daemon on 127.0.0.1:11211 and libmemcache as required by the php-memcached library. I have restarted apache tons of times and even done a machine restart.
Does anyone know why the modules/extensions show up in the command line but not in my phpinfo()? I am literally stumped, after 3 hours of googling, I am just about ready to give up.
Also, please note, my phpinfo() outputs my ini files as follows AND they are both the exact same file:
Configuration File (php.ini) Path: /etc
Loaded Configuration File: /private/etc/php.ini
UPDATE:
Apache is failing to load the extension.
[Fri May 14 04:22:26 2010] [warn]
Init: Session Cache is not configured
[hint: SSLSessionCache] PHP Warning:
PHP Startup: Unable to load dynamic
library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcached.so'
- (null) in Unknown on line 0 PHP Warning: PHP Startup: Unable to load
dynamic library
'/usr/lib/php/extensions/no-debug-non-zts-20060613/memcache.so'
- (null) in Unknown on line 0
Does anyone know why or how this would happen? Both of the files referenced above DEFINITELY ARE there. Should I move this question to server fault?
Your webserver is probably using mod_php, which is a seperate bit of code from the standalone (CLI) interpreter. If they are both using the same ini file, and the memcache extension is configured in the ini file, then it sounds like for some reason, the mod_php is failing to load the extension - check your webserver error_log for startup errors.
It may be that the mod_php was compiled without memcache support (most extensions need to have a stub file linked into the php code, even though the bulk of the code is not linked until run time). Or it may be a permissions problem on the shared object file. Or your webserver may be running chroot, and unable to find the extension (which would also mean that although the ini files appear to have the same path, this is relative to different roots).
HTH
C.
because both versions use different php.ini
place your php.ini into location noted in the phpinfo() outout
I would suspect that the issue revolves around permissions. When you run php from comand line, it runs as the user invoking it. When run as an apache module, it runs as "nobody".
I would assume that the memcached.so file, or the directory it's in does not have proper permissions.
I stumpled upon this post and was having the exact same problem with an extension in my php -i but not in phpinfo(). Mine was a permissions problem because of selinux on a CentOS machine. I had to change ownership and permissions and now it is working as expected.
Set php path in environment variables as given below.
Right-click on "My Computer"
Properties
Advanced Tab > Environment Variables
Under System variables, scroll down to find "Path", select and click on Edit.
Add path to your php install on the end (make sure to precede with semi-colon ";"). Example: ";C:\php7"
Click Ok.

Runkit : does not work on a linux server

I have a problem with PECL::Runkit with this little example
index.php contain <?php
runkit_import('a.php');
runkit_import('b.php');
Doublon::get();
a.php et b.php each contain the same code
class Doublon
{
static function get() { echo "class " . __FILE__; }
}
On my PC (Windows XP, Wampserver 2, php 5.2.9-2, runkit DLL bundled with
Wamp) it work and index.php show
class C:\wamp2\www\utilitaires\essais\runkit\b.php
On my Linux CentOS 5 server, PHP 5.2.10, Runkit compiled by hand
Warning: runkit_import() [function.runkit-import]: class doublon not
found in /shares/public/cedric/test/index.php on line 2
Warning: runkit_import() [function.runkit-import]: Cannot redeclare
class doublon in /shares/public/cedric/test/index.php on line 2
Warning: runkit_import() [function.runkit-import]: class doublon not
found in /shares/public/cedric/test/index.php on line 3
Warning: runkit_import() [function.runkit-import]: Cannot redeclare
class doublon in /shares/public/cedric/test/index.php on line 3
Fatal error: Class 'Doublon' not found in
/shares/public/cedric/test/index.php on line 4
One problem : runkit's make test give me 100% of tests failed, but I still don't know why.
The runkit version from the linux distribution just make crash Apache :
PHP Startup: Timezone database is corrupt
I dropped xdebug, return to php 5.2.9, but the errors are the same
Thanks in advance, Cédric
The Package site says:
WARNING: 0.9 does not compile with PHP 5.2+ so use the CVS version instead.
Are you using the CVS version?
The up-to-date runkit extension can be found on http://github.com/zenovich/runkit
Anyway, as I know, runkit never had a feature to define new class on importing. It only can add or change members of existing classes. If you really want this, you can open the feature-request on http://github.com/zenovich/runkit
To determine why you get different results on your platforms, I need to know the versions of runkit and PHP for both of them. You can get all the information using the command 'php -i'.

Categories