Laravel - php artisan migrate issue - driver not found - ubuntu - php

I am using xampp in ubuntu, while i do php artisan migrate, it showed PDO Exception could not find driver
Then to fix that
I showed me to install mbstring, php_curl etc., i have installed mbstring, then while install php_curl i got error can't locate
root#allau-Inspiron-5558:/home/allau# sudo apt-get install php5-curl
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package php5-curl
when i type php --ini it showed the following
root#allau-Inspiron-5558:/home/allau# php --ini
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File: /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed: /etc/php/7.0/cli/conf.d/10-opcache.ini,
But i am using xampp in ubuntu, i guess it points the php.ini of /etc/php/7.0 but i want to use php of /opt/lampp how can i do that ?
help pls

PHP that you are using via CLI is different from the one that is being used by XAMPP. XAMPP brings its own PHP, and if you want to run that one via CLI instead the one that you probably got with Ubuntu, then you should add it to your PATH:
nano ~/.bashrc
Then add this line at the end of the file:
export PATH=/opt/lampp/bin:$PATH
...and save it (ctrl+o -> enter -> ctrl+x)

Related

Xdebug on macOS 10.13 with PHP 7

So macOS High Sierra 10.13 now comes with PHP 7.1. While configuring Apache I also created a new /etc/php.ini from the /etc/php.ini.default file, made sure to check that is was being loaded by PHP after restarting Apache, however the version of Xdebug extension that ships with macOS 10.13 doesn't seem to load or show up when you run phpinfo();
My php.ini is definitely being loaded:
$ php -i | grep php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Here's what my /etc/php.ini looks like where I configure Xdebug:
[xdebug]
zend_extension = "/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so"
xdebug.remote_enable=on
xdebug.remote_log="/var/log/xdebug.log"
xdebug.remote_host=localhost
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
[Update, fixed that typo here...]
However, Xdebug doesn't load and checking php -i give no results:
$php -i | grep xdebug
PHP Warning: Method xdebug_start_function_monitor() cannot be a NULL
function in Unknown on line 0
PHP Warning: xdebug: Unable to register functions, unable to load in Unknown on line 0
Segmentation fault: 11
And yes, the path to the file is correct:
$ ls /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so*
This used to work on PHP 5 so I hope someone can help me and anyone else in future struggling with this issue.
When I check my apache log I get the following error:
Failed loading /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so: dlopen(/usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so, 9): Symbol not found: _xdebug_monitored_function_dtor
Referenced from: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
Expected in: flat namespace
in /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
I'm not making progress in terms of find out how I can resolve this error:
Symbol not found: _xdebug_monitored_function_dtor
Ok so I finally got it running myself it works perfectly! I'm assuming that the xdebug binary that comes with macOS High Sierra (found under: /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so) is not compatible with PHP7's new Zend engine.
So I downloaded the latest source from the xdebug website and did the following:
Installed autoconf with brew;
Run phpize to configure the build for the new Zend engine;
Run ./configure
Run make
Now the new binary is under modules/xdebug.so
However macOS System Integrity Protection (SIP) will prevent you from overwriting the xdebug.so under /usr/lib/php/extensions/. I didn't want to disable this so I created a new directory path under /usr/local/lib/php/extensions/ and copied the new binary to this location. I'm not sure if this directory is the best place to put it or if this is bad practice but it worked for me.
Finally I reconfigured my php.ini to use the new binary and everything worked perfectly!
In order to install it you have to have xcode command line tools.
So you need to run:
xcode-select --install
Then you need to install autoconf:
brew install autoconf
Then you have to download the code from here.
After that you have to run in the folder of the source code:
phpize
./configure
make
sudo cp modules/xdebug.so /usr/local/php/extensions (if the directory doesn't exist go and create it)
And finally inside php.ini add
zend_extension=/usr/local/php/extensions/xdebug.so
After that you can enable xdebug inside php.ini and restart apache
sudo apachectl restart
you made a typo in "zend_extention". this should be zend_extension.
and i think the full path is unnecessary
zend_extension=xdebug.so
should be enough
If you have brew installed with multiple PHP versions i.e. 7.1, 7.2 and 7.3 on Mac OS X mojave, you can to do the following:
Install autoconf with brew brew install autoconf.
Change to the PHP version that you want Xdebug on, run brew unlink php#7.1 && brew link --force --overwrite php. This will switch from PHP 7.1 to PHP 7.3.
Download the latest Xdebug source from xdebug website.
Extract the Xdebug tar and navigate to extracted directory, where you'd see all the files.
Run phpize to configure the build for the new Zend engine.
Run ./configure.
Run make.
Xdebug extension xdebug.so gets compiled in modules directory.
Create a new directory path under /usr/local/lib/php/7.3.1/extensions/ and copy xdebug.so to this location. Here, 7.3.1 is the current version that I switched earlier, change this to match your PHP version.
Open php.ini in an editor and enter
zend_extension="/usr/local/lib/php/7.3.1/extensions/xdebug.so" then save the change.
Run php -v and it will show Xdebug has been configured correctly.
If you want to configure Xdebug on another PHP version then just repeat from step 2 all the way to 11. As mentioned in earlier post, this way you don't need to disable/enable System Integrity Protection on Mac OS X.
For anyone arriving late at this party, the initial attempt in the question seems to work just fine in macOS 10.13.6
Hello for everyone that got error trying to install xDebug on Mac.
error: unknown type name 'uint64_t'
There are files in your local/bin/include that causes this error. By removing them you get rid of the error. Though, you might have to reinsatall brew.
https://github.com/cython/cython/issues/2009

ubuntu litespeed php7.0 got a weird php.ini path

Ubuntu 16.04.2
LSPHP7.0
wget -O - http://rpms.litespeedtech.com/debian/enable_lst_debain_repo.sh | bash
apt install -y lsphp70
Then I added /usr/local/lsws/lsphp70/bin to $PATH and made a symlink for /usr/local/lsws/lsphp70/bin/php7.0 to /usr/local/lsws/lsphp70/bin/php. This way I can run php in terminal as cli version.
apt install composer
composer require geoip2/geoip2:~2.0
I got an error said the requested PHP extension curl is missing from your system.
And also it said
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
But when I run php -i | grep php.ini it shows the ini is not /etc/php/7.0/cli/php.ini but /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Further more, I run php --ini, it shows:
Configuration File (php.ini) Path: /usr/local/lsws/lsphp70//etc/php/7.0/litespeed/
Loaded Configuration File: /usr/local/lsws/lsphp70/etc/php/7.0/litespeed/php.ini
Scan for additional .ini files in: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/
Additional .ini files parsed: /usr/local/lsws/lsphp70//etc/php/7.0/mods-available/curl.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/imap.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/json.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/mysqli.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/opcache.ini,
/usr/local/lsws/lsphp70//etc/php/7.0/mods-available/pdo_mysql.ini
How can php cli get /etc/php/7.0/cli/php.ini as its php config file? Anyone gives a clue? thanks.
Ubuntu normally installs system default php(currently php7.0) to /usr/bin/php
Composer will normally call the PHP defined in $PATH, usually /usr/bin/php.
The Error "the requested PHP extension curl is missing from your system" means Ubuntu system default php7.0 curl is missing. To resolve:
apt-get install php7.0-curl
So far, it should resolve your problem already.
LiteSpeed Web Server normally use LiteSpeed API to communicate with PHP engine, which is faster than other APIs. In LiteSpeed Ubuntu/Debian repo, it provides different versions of lsphp, which will be at different location other than system default location, normally at /usr/local/lsws/lsphpxx/bin/.
Composer will normally use system default php location as explain above. If you want to overwrite PHP path to use lsphp70 php binary, you will need to add this path to the beginning of $PATH.
export PATH="/usr/local/lsws/lsphp70/bin/:$PATH"
This way, when you run:
which php
System should use the php found first in the PATH, which is /usr/local/lsws/lsphp70/bin/php
In this case, when you see similar php-curl missing error message, you should run:
apt-get install lsphp70-curl
to fix the problem.
To make the new PATH permanently, you can edit ~/.profile or .bashrc, or any other similar way, which is beyond the discussion of this topic.

pdo_mysql is not available on centos 6.7

I have a CentOs 6.7 server.
I have problem to make pdo_mysql available on apache2.
following shows for Command line:
myserver$ php -m
PDO, pdo_mysql, pdo_sqlite
but phpinfo(), shows only PDO and pdo_sqlite
I already included following in php.ini
extension=pdo_mysql.so
extension=pdo.so
And restarted the Apache with:
sudo service httpd restart
It looks like, pdo_mysql is installed on a different php.
when I search the server for pdo.so and pdo_mysql.so, I get pdo.so in three places, but pdo_mysql in two places.
myserver$ locate pdo.so
/usr/lib64/php/modules/pdo.so
/usr/lib64/php-zts/modules/pdo.so
/var/opt/remi/php56/root/usr/lib64/php/modules/pdo.so
myserver$ locate pdo_mysql.so
/usr/lib64/php/modules/pdo_mysql.so
/usr/lib64/php-zts/modules/pdo_mysql.so
And Apache installation in phpinfo() shows:
Loaded Configuration File /opt/remi/php56/root/etc/php.ini
So my recent php upgrade to php 5.6 is missing pdo_mysql.
other php installation has it, but I don't know how to force the pdo_mysql installation to install it to /var/opt/remi/php56/
I used following for installing pdo-mysql:
yum install pdo-mysql
So, it installed it under, /usr/lib64/php/, but not under,/var/opt/remi/php56/ Any help or advice is appreciated
It seems you are confused by the 2 available PHP stacks in remi repository.
php-* packages = base packages with configuration in /etc
php56-php-* packages = software collections for parallel installation with configuration in /opt
Also see the FAQ
And Apache installation in phpinfo() shows: Loaded Configuration File /opt/remi/php56/root/etc/php.ini
This means you are using the SCL version. So you need php56-php-mysqlnd
I already included following in php.ini
You never have to change the php.ini, each package provides its configuration file which enable the extension (and ensure correct load order, e.g. pdo "before" pdo_mysql)
I recommend you follow the Configuration Wizard results
Ok, I finally found the solution to the problem.
I was trying to install missing pdo_msyql extension, but yum was saying the package is not available.
Then by installing following the problem was solved.
yum install php-ZendFramework-Db-Adapter-Pdo-Mysql.noarch
Thanks everyone for your helps.

Class 'MongoClient' not found

I'm trying to make this code run:
<?php
$m = new MongoClient("mongodb://54.72.237.242");
$db = $m->tilbud;
?>
Everytime I got the same error:
Fatal error: Class 'MongoClient' not found in C:\xampp\htdocs\conexion.php
I've been reading about this problem the whole day but anything solves my issue (I guess it's something I'm doing wrong).
I downloaded the php_mongo.dll, I copied it in xampp/php/ext and I added extension=php_mongo.dll in the php.ini archive.
I've added 4 more dll's because I'm not sure which one I have to use:
extension=php_mongo-1.5.4-5.5-vc11-nts
extension=php_mongo-1.5.4-5.5-vc11
extension=php_mongo-1.5.4-5.5-vc11-nts-x86_64
extension=php_mongo-1.5.4-5.5-vc11-x86_64
So now im getting 5 warnings instead of one. At the end I guess one of them will work and I'll delete the other 4.
Things I tried and I'm sure they are ok:
The extension_dir is pointing to the correct folder.
The php.ini that I modified is the one that xammp loads.
Phpinfo dosen't show anything about mongo.
What more can I try ?
Edit
I tried
echo extension_loaded("mongo") ? "loaded\n" : "not loaded\n";
and it always says 'not loaded'.
Edit
Finally!
The problem was the dll's name. It has to be 'php_mongo.dll' and I was trying to load the full name dll as I said at the begining of this post. So I changed the correct dll for me (extension=php_mongo-1.5.4-5.5-vc11) for extension=php_mongo.dll and voilĂ !
You have not installed MongoDB PHP driver please see this link http://www.php.net/manual/en/mongo.installation.php
Update sources
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
Install MongoDB PHP Driver
sudo apt-get install php5-dev php5-cli php-pear -y
sudo pecl install mongo
Open your php.ini file and add to it:
extension=mongo.so
Restart apache
sudo /etc/init.d/apache2 restart
Other helping info:
this should help to find your php.ini file:
php -i | grep 'Configuration File'
On Ubuntu it shows this:
Configuration File (php.ini) Path => /etc/php5/cli
Loaded Configuration File => /etc/php5/cli/php.ini
take a note, that you run this command from cli (command line) so for your true php.ini go to folder apache2 instead of cli :)
For those arriving on this page with PHP 7 installed:
The MongoCLient class was provided by pecl install mongo.
But pecl/mongo is not available for php7 and deprecated in favor of pecl/mongodb. But with pecl/mongodb you'll need to use MongoDB\Driver\Manager instead of MongoClient (warning on page says so too).
See here for further reading.
This said, you will need an abstraction layer on top of the PHP MongoDB\Driver\Manager. This is provided by mongodb/mongo-php-library.
You will need to refactor stuff like:
\MongoClient to \MongoDB\Client
\MongoCollection to \MongoDB\Collection
\MongoClient->selectDB to \MongoDB\Client->selectDatabase
\MongoClient->listDBs to \MongoDB\Client->listDatabases
also output is not an array but an iterator, so you'll need to use iterator_to_array, along with edits to how you use the resulting object
\MongoCollection->getName to \MongoDB\Collection->getCollectionName
\MongoCollection->update to \MongoDB\Collection->updateOne or updateMany
\MongoCollection->remove to \MongoDB\Collection->deleteOne
\MongoCollection->batchInsert to \MongoDB\Collection->insertMany
The answer is indeed to follow the instructions.
I was missing the very important require line that must come before creating the new mongodb object:
<?php
require 'vendor/autoload.php';
$client = new MongoDB\Client("mongodb://localhost:27017");
And of course you need to run this command in the root of your project as per the instructions:
composer require mongodb/mongodb
Getting the same error and now it's solved.
I am using Linux Mint. To solve this issue I added extension=mongo.so in two directories:
/etc/php5/cli/php.ini
/etc/php5/apache2/php.ini
install the driver, I have for example php5.6:
sudo apt-get install php5.6-mongo
From this page:
Note: Additional DLL dependencies for Windows Users:
In order for this extension to work, there are DLL files that must be available to the Windows system PATH
your php version and dll file version should be same check it if versions are not same then update your xampp php according to the available dll version.

pgsql.so is not loaded in PHP

I've been tasked to create a PHP app which accesses an existing PostgreSQL database. This is my first time working with Postgre, not to mention the PHP has already been installed in the Linux box on which the app is supposed to run. I have no experience setting up this stuff, I just code.
My question is that I can't seem to get the Postgre extension working in PHP. I checked the php.ini file, there were no "extension=..." lines. So I added "extension=pgsql.so". I then checked the "extension_dir" and found that there were only 2 files in there (ldap.so, phpcups.so), I added a pgsql.so file taken from another Linux box. I restarted httpd. And it does not work. I couldn't find any "pgsql" or "postgre" in phpinfo().
Forgive my noobness. I know too little Linux. I would really appreciate it if you can point me to the right direction.
I used the suggestion given by number5:
Dude, I'm on RedHat. I used the "yum" version of the command you gave, and I got this:
[root#perseus ~]# yum install php-pgsql
Loading "installonlyn" plugin
Setting up Install Process
Setting up repositories
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=5&arch=x86_64&repo=extras error was
[Errno 4] IOError:
Error: Cannot find a valid baseurl for repo: extras
UNFORTUNATELY, the Linux server I'm using is NOT connected to the Internet. Any other way to install?
It depends on which Linux distro you are using.
If you are using Ubuntu/Debian, you need to:
sudo apt-get install php5-pgsql
Fedora/CentOS
yum install php-pgsql
usually you can find out which distro you are on by:
ls /etc/*-release
On CentOS extensions create separate *.ini file one per each php extension in /etc/php.d
So, don't alter main *.ini file, but create /etc/php.d/pgsql.ini and add there a line
extension=pgsql.so
Then you will need to restart Apache using
service httpd restart
But the best automated way is to just type
yum install php-pgsql
In your case that didn't work because of some problems in yum configuration. Go to /etc/yum-repos.d
Type
nano /etc/yum.repos.d/CentOS-Base.repo
Scroll down to [extras] section and ensure it is like this:
#additional packages that may be useful
[extras]
priority=1
name=CentOS-$releasever - Extras
=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Correct it if needed, save file (Ctrl-X) and do the following:
yum clean all
yum upgrade
Afterwards try to repeat
yum install php-pgsql
Remove the .so file you've copied from the other machine (though it might work, there's no need to take the risk)
Use the distribution's package manager to install the php_pgsql/php5_pqsql module
Restart the apache and try again. Maybe the module has been added to an .ini file automagically
If not, run <?php echo 'ini: ', get_cfg_var('cfg_file_path'); to see which php.ini you have to edit
edit this ini file
restart the apache
My operation system Linux mint kde and there was same issue
pg_connect()
You must install if you are use php5.6
sudo apt-get install php5.6-pgsql
After you must change extention name in "php.ini" file.
;extension=php_pgsql.dll
'dll' to 'so'
For example
extension=php_pgsql.so

Categories