I ran a PHP server with postgresql on my college computers which works fine, however on my local machine (which runs MacOS), I get the following error message:
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
Now, I thought it's an issue of missing the postgresql packages for php, so I used brew to install the php postgresql packages. I ran the following commands:
brew install postgresql
brew install php55 --with-postgresql
brew install php55-pdo-pgsql
However, even after running these commands I get the same error when running the php server, i.e.
Call to undefined function pg_Connect() in /Users/mac/Documents/<... the remaining path to php file>.php on line 2
The php version I have is 5.5.30:
mac$ php -v
PHP 5.5.30 (cli) (built: Oct 23 2015 17:21:45)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2015 Zend Technologies
Please could you suggest what I am doing wrong to install the packages. I read on stack overflow that the packages can be installed with an apt-get command on linux, however I'm not sure as to what the solution is with the Mac operating system.
Thanks in advance.
The solution was edit the php.ini on your server then find this below line and uncomment that line.
extension="pgsql.so"
then restart the server apache and test it out again.
Also, check this link for the steps regarding installation of the postgress to mac OS.
Related
To be more precise, I don't even see where PHP 7.1 is installed.
When I run php -v in the terminal, I get:
PHP 7.1.23 (cli) (built: Feb 22 2019 22:19:32) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
So I thought I would use Homebrew to unlink 7.1 and install 7.2. Should be straightforward. However, running brew unlink php71 returns an error saying:
No such keg: /usr/local/Cellar/php71
And, indeed, in /usr/local/Cellar there is nothing resembling a PHP version.
I tried running brew update and brew upgrade just in case, but it didn't help.
I also tried running a PHP application locally and did phpinfo() within the application, and I got the same version info I got in the console.
When I ran whereis php it gave me the result /usr/bin/php. When I ran whereis php71 it came up with nothing which, I suppose, is to be expected in this situation.
The question is, how do I replace PHP 7.1 with 7.2 in the least painful way? Ideally, I would like to get brew to do this so I can update future version through brew as well.
Mac OS has its own PHP version installed, which is complete independent from brew.
You need to force link your brew version.
brew link php#7.2 --force
If I open Terminal on my MacOS and view my php version the result is:
Jacks-MBP:Projects jackrobson$ php -v
PHP 7.2.12 (cli) (built: Nov 29 2018 01:59:12) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.12, Copyright (c) 1999-2018, by Zend Technologies
I'm also running httpd as my Apache server:
Jacks-MBP:Projects jackrobson$ httpd -v
Server version: Apache/2.4.37 (Unix)
Server built: Nov 8 2018 08:13:24
However, upon trying to configure Laravel of which I did by running this command without any errors:
composer create-project laravel/laravel demowebsite
And configure my vhost, I see this error when I view demowebsite.test:
Parse error: syntax error, unexpected '=' in /Users/jackrobson/Projects/demowebsite/vendor/laravel/framework/src/Illuminate/Support/Arr.php on line 384
I think maybe this because I don't have the dependencies needed?
Is that true or would the composer install of laravel failed?
I'm trying to figure out if the dependencies are missing.
Weirdly, upon looking at phpinfo from the base of the laravel demosite it says:
PHP Version 7.0.32
Not sure why it's not using version 7.2 as is visible in my Terminal.
Maybe that is issue.
I will investigate further and update but anyone with more wisdom who understands this, I'd appreciate a point in the right direction.
Many thanks
Edit:
Following user Caddy DZ's suggestion "Try configuring httpd to use php 7.2 instead or remove version 7.0 completely"
I was able to switch php versions using a script I initially configured php, apache, etc. last year
$ curl -L https://gist.githubusercontent.com/rhukster/f4c04f1bf59e0b74e335ee5d186a98e2/raw > /usr/local/bin/sphp
$ chmod +x /usr/local/bin/sphp
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
If that doesn't work for any observers, try this additional command:
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
This script made it easy for me to change httpd php version with the command:
Jacks-MBP:Projects jackrobson$ sphp 7.2
Sorry, but php#7.2 is not installed via brew. Install by running: brew install php#7.2
Jacks-MBP:Projects jackrobson$ brew install php#7.2
Which ran without errors and now httpd is using 7.2 and the Laravel install no longer shows the syntax error. Huzzah!
Thank you for your assistance Caddy DZ. :)
I hope these notes prove helpful to anyone who encounters a similar issue.
Try configuring httpd to use php 7.2 as the default fpm instead or uninstall version php 7.0 completely if you don't need it.
Hope this helped
When trying to run artisan commands I get the following error
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Memcached' not found
I had recently been been working on another project that used Lumen 5.3 and had no problem running artisan commands. Both projects are on the same virtual box and apart from the Lumen versions there is no differences in server setup.
I've checked that Memcached is running and there is no problems.
I've tried composer dump-autoload, deleting the vendor folder and re-installing but none of these have made a difference.
I'd prefer not to have to go back to 5.3 if possible.
Is there a way to solve this issue?
Had the same problem.
Check if you have the memcached extension installed for the php version that you're using, and check also if it is correctly configured in the php.ini file (it could be looking in the wrong directory).
looks like your memcahed is not installed or not properly configured.
for quick solution ,
use file cache driver instead of memcached
CACHE_DRIVER=file
Ubuntu 16.04 LTS, try this:
sudo apt-get install php-memcached
Just to add to the os specific responses. Here is the one using OS/X and homebrew.
First you have to determine which version of PHP you're using locally.
$ php -v
PHP 7.0.19 (cli) (built: May 21 2017 11:56:11) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
$ brew search memcached
homebrew/php/php53-memcached homebrew/php/php70-memcached
homebrew/php/php54-memcached homebrew/php/php71-memcached
homebrew/php/php55-memcached libmemcached ✔
homebrew/php/php56-memcached memcached ✔
Since I'm running PHP 7.0 I chose to install homebrew/php/php70-memcached
$ brew install homebrew/php/php70-memcached
If you don't have homebrew installed go to https://brew.sh/ and install it to use these instructions. This was the command last time I used it.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Once I was done with all that then I tested by clearing the cache.
$ php artisan cache:clear
Cache cleared successfully.
$
Cheers, this fixed it for me for local development.
If you are on Mac OSX, you will need to install Memcached and its PHP dependencies via Homebrew.
brew update
brew doctor
brew install memcached
Then check your PHP version and install your relevant PHP hooks for Memcached.
php -v
in my case...
PHP 7.1.4 (cli) (built: Apr 14 2017 15:02:16) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
So I used:
brew install php71-memcached
But you can lookup your required version using
brew search memcached
Once you have performed these steps you will probably get a new error
No Memcached servers added.
So fire it up with
brew services restart memcached
Done!
I'm currently running a Laravel 5.1 app with php 5.5 and nginx on my Mac OSX, I want to update php to php 7.0 so I typed the following in terminal:
brew unlink php55
brew uninstall php55
brew install --with-fpm --with-mysql php70
It works and after that,
php -v
gives me the following response:
PHP 7.0.0RC4 (cli) (built: Oct 5 2015 03:44:48)
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0-dev, Copyright (c) 1998-2015 Zend Technologies
I then restarted nginx, but when I tried to echo phpinfo in my existing Laravel app, it still says current version of php is 5.5, what else do I need to setup for Laravel 5.1 to run on top of my newly installed php 7.0?
Well, turns out I didn't restart php-fpm, so after killed the old php-fpm and then
php70-fpm start
nginx -s reload
Everything worked out perfectly.
I have running Xampp with PHP5.5 on Fedora from Apache Friend, with default settings what the installer package do on Linux.
When I install FFMPEG successfully and try to load from php.ini it always says:
*
11-Oct-2013 14:05:51 Europe/Berlin] PHP Warning: PHP Startup: ffmpeg: Unable to initialize module
Module compiled with module API=20060613
PHP compiled with module API=20121212
These options need to match
in Unknown on line 0
*
The only thing which is confusing me is that when I did phpize even that I already installed xampp server which means I have PHP running. FFMPEG phpize did not work and I had to install php-devel. Does that mean that FFMPEG is configured with PHP, other than the installed with XAMPP? I am not sure what is happening. Whatever I do I always receive this error message in php_error_log file.
It is amazing :) that I just run below command to see what version of PHP is, I have and below are the results which are shocking one because I am in a feeling that I have PHP 5.5 installed and running from XAMMP.
[root#localhost ~]# php -v
PHP 5.2.6 (cli) (built: May 8 2008 08:53:44)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
How can I get this covered that if I simple install XAMPP server on linux and want to install and configure FFMPEG along with?
My guess would be that the versions of php and the module you installed do not match. So run make sure both packages are installed from the same source and are both current.
EDIT: According to the XAMPP site, Fedora is not supported, they specify Ubuntu, SuSE, RedHat, Mandrake and Debian. So I would make sure you do not use the php package provided by Fedora. Or (if you have the liberty), choose a different OS.