I'm developing a PHP application. I just moved a bunch of files over to the production server, to discover that PDO is apparently not installed (Fatal error: Class 'PDO' not found in [file] on line [line]). The prod server is using PHP 5.3.6; according to the documentation I've found, "PDO and the PDO_SQLITE driver is enabled by default as of PHP 5.1.0".
I have very little experience administering PHP. How do I tell if this module is installed but disabled, or absent altogether? And what do I need to do to get it running?
Generally you can just do phpinfo(); to find out what modules are installed.
Or from the commandline:
php -m
Additionally you could use: class_exists('PDO') to find out whether the PDO class indeed is accessible.
In the terminal type:
php -i |grep PDO
The -i is used to display the output of phpinfo().
The |grep will filter the list to the ones containing PDO.
Related
I'm using nginx in docker from trafex/php-nginx
But I don't get SQLite working.
The following php code
<?php
$db = new SQLite3('/var/private/anmeldungen.db');
$db->close();
throws this error [error] 9#9: *33 FastCGI sent in stderr: "PHP message: PHP Fatal error: Uncaught Error: Class "SQLite3" not found in /var/www/html/phpinfo.php:3
I'm using a dockerfile to install the sqlite package:
FROM trafex/php-nginx:latest
USER root
RUN apk add php8-pdo_sqlite
USER nobody
And in the PHPInfo I can see that the package is loaded:
Does anyone have an idea?
Your package is wrong, PDO is PHP Data Object which is a higher layer designed to be able to work with any lower database protocol such as SQLite, MySQL, Postgres..., so implementing via PDO may help you a lot in long run if you would like to switch to another database without changing much (there may be some incompatible features but not much) of your source code.
To init a SQLite via PDO you have to do so:
$dbh = new PDO('sqlite:/tmp/foo.db');
You can read more about that here https://www.php.net/manual/en/ref.pdo-sqlite.php.
If you want to stick with native SQLite (to use your SQLite3 class), you will have to install package php8-sqlite3 but not the php8-pdo_sqlite3
apk add php8-sqlite3
This will work with your current code.
SQLite is included with PHP, you have to uncomment it in the php.ini file. But first you have to uninstall the one you installed because otherwise PHP will complain that there are two. I had the same problem, albeit not inside a Docker container. PHP agreed that SQLite was installed but the CLI wouldn't use it.
My problem is that whatever I do I can't seem to generate entities with the command :
php bin/console doctrine:mapping:import AppBundle xml
The error I get everytime is a classic:Pics of the error
I already put the good database parameters in parameters.yml. The file config.yml is ok too.
My Php version is :
PHP 7.0.26 (cli)
My php.ini in my app folder already contains :
extension=pdo.so
extension=pdo_mysql.so
extension=php_pdo_mysql.dll
I already installed all the php7 required.
The result of the command :
php -i
contains :
PDO
PDO support => enabled
PDO drivers =>
I don't know what to do now, I can't seem to find the origin of the problem.
I have to add that I'm doing all this on Cloud9.
Thank you for your attention.
There could be at least two reasons:
pdo_mysql is not configured in php.ini for cli
pdo_mysql is not installed at all
Last time I was using phpmyadmin, it was using mysql_*, instead of PDO
I think you should execute, to see if you have all the required dependencies.
php bin/symfony_requirements
Also referre to http://symfony.com/doc/3.4/reference/requirements.html
In the end my partner reinstalled everything from scratch.
The problem seemed to be an incompatibility between the php version used and the symphony version used.
Thank you all for your time !
I've pasted the example from php.net for using memcached in php and I'm getting:
Fatal error: Class 'Memcache' not found
I have this in my php.ini:
[memcache]
memcache.hash_strategy = "consistent"
memcache.max_failover_attemps = 100
memcache.allow_failover = 1
Here's info from php -i and php -m respectively:
php -i | grep -i memcache
memcached
memcached support => enabled
libmemcached version => 0.37
Registered save handlers => files user sqlite memcached
php -m | grep -i memcache
memcached
So php seems to have loaded memcached as a module, and php info says that it is loaded and is using v .37. I have not tried yet via apache, I've only been using this through cli right now. Any thoughts?
There are two extensions for memcached in PHP, "memcache" and "memcached".
It looks like you're trying to use one ("memcache"), but the other is installed ("memcached").
Dispite what the accepted answer says in the comments, the correct way to install 'Memcache' is:
sudo apt-get install php5-memcache
NOTE Memcache & Memcached are two distinct although related pieces of software, that are often confused.
EDIT
As this is now an old post I thought it worth mentioning that you should replace php5 with your php version number.
I found solution in this post: https://stackoverflow.com/questions/11883378/class-memcache-not-found-php#=
I found the working dll files for PHP 5.4.4
I don't knowhow stable they are but they work for sure. Credits goes to this link.
http://x32.elijst.nl/php_memcache-5.4-nts-vc9-x86.zip
http://x32.elijst.nl/php_memcache-5.4-vc9-x86.zip
It is the 2.2.5.0 version, I noticed after compiling it (for PHP 5.4.4).
Please note that it is not 2.2.6 but works. I also mirrored them in my own FTP. Mirror links:
http://mustafabugra.com/resim/php_memcache-5.4-vc9-x86.zip http://mustafabugra.com/resim/php_memcache-5.4-nts-vc9-x86.zip
For OSX users:
Run the following command to install Memcached:
brew install memcached
The right is php_memcache.dll. In my case i was using lib compiled with vc9 instead of vc6 compiler. In apatche error logs i got something like:
PHP Startup: sqlanywhere: Unable to
initialize module Module compiled with
build ID=API20090626, TS,VC9 PHP
compiled with build ID=API20090626,
TS,VC6 These options need to match
Check if you have same log and try downloading different dll that are compiled with different compiler.
I went into wp-config/ and deleted the object-cache.php and advanced-cache.php and it worked fine for me.
I am using MAMP Pro to manage my development environments, the PHP is version 7.0.12 and is running in module mode.
I have added the pcntl module for PHP and have compiled it following the directions from this answer.
The pcntl.so file is in my /Applications/MAMP/bin/php/php7.0.12/lib/php/extensions/no-debug-non-zts-20151012 folder. Also, on my vhost I can output phpinfo() and verify that the extension is installed and additionally checked it by function_exists('pcntl_signal') which returns true.
However, I can't get it to work when running PHP from the terminal. I am using the one that MAMP installs and am invoking it through /Applications/MAMP/bin/php/php7.0.12/bin/php. However, I get the error that the function pcntl_signal does not exist.
Also running /Applications/MAMP/bin/php/php7.0.12/bin/php -i | grep pcntl doesn't output anything.
Is there a way to make the pcntl module available to PHP through the command line in addition to the one apache is using?
There are two separate ini files that MAMP uses for PHP.
One is editable through the GUI, the other needs to be manually edited. For this PHP version the extension must be added in /Applications/MAMP/bin/php/php7.0.12/conf/php.ini
After adding extension=pcntl.so into the above ini file, running php -i | grep pcntl will output
pcntl
pcntl support => enabled
I'm trying to configure a PHP installation (5.4.3) with MYSQL (5.0.91) for use with a PHP web application that relies on the MDB2 mysql module. When I install using PEAR, pear tells me that PHP does not have the required mysql extension.
Some googling around lead me to check the PHP.ini file, in which I found that extension=php_mysql.dll was commented out. I turned this on and restarted php. PHP complains that it can't find php_mysql.dll.
I realized that this might have been because I didn't install php with the --with-sql flag turned on. Reconfiguring leaves me with the following error:
checking for MySQL support... yes
checking for specified location of the MySQL UNIX socket... /project/mullenl
checking for mysql_close in -lmysqlclient... no
checking for mysql_errno in -lmysqlclient... no
configure: error: Try adding --with-zlib-dir=<DIR>. Please check config.log for more information.
A quick look at the configuration log shows the problem:
/usr/bin/ld: cannot find -lmysqlclient
When I check my lib directory in my mysql installation the following things are present:
libdbug.a
libmysql.imp
libmysqlclient.so*
libmysqlclient.so.15.0.0*
libmysqlclient_r.so*
libmysqlclient_r.so.15.0.0*
libmysys.a
libndbclient.la*
libndbclient.so.2*
libmygcc.a
libmysqlclient.a
libmysqlclient.so.15*
libmysqlclient_r.a
libmysqlclient_r.so.15*
libmystrings.a
libndbclient.a
libndbclient.so*
libndbclient.so.2.0.0*
I'm not too sure what to do next, but really need to configure PHP in this way to support the MDB2:MYSQL module. I suspect (?) that the reason I can't do this is because I don't have the development version of MYSQL installed, but I'm not sure this is the case. Any thoughts, ideas or advise would, as always, be greatly appreciated!
The php_mysql.dll extension is only used on Windows, it looks like you are on Unix/Linux.
If you view your phpinfo(), what are your configure options?
You can build mysql into PHP by adding --with-mysql=mysqlnd to your ./configure options.
If you have a custom version of mysql that is compiled on the system, then specify the path to where it is installed instead of using the mysql native driver (mysqlnd) --with-mysql=/usr/lib