Jinto Antony
Jinto Antony

Reputation: 468

How to install PDO_PGSQL for PHP 8 on Mac OS Big Sur having M1 Chip?

I have been trying to install pdo_pgsql. Homebrew is not working. Adminer needs this extension for accessing the DB. How to solve the issue?

PgSQL and PDO_PgSQL extensions are already enabled on the php.ini file. But, still, Adminer shows the Error:

None of the supported PHP extensions (PgSQL, PDO_PgSQL) are available.

When running $ php artisan serve, it shows the following error

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /opt/homebrew/lib/php/pecl/20190902/pdo_pgsql (dlopen(/opt/homebrew/lib/php/pecl/20190902/pdo_pgsql, 9): image not found), /opt/homebrew/lib/php/pecl/20190902/pdo_pgsql.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/pdo_pgsql.so, 9): image not found)) in Unknown on line 0

Upvotes: 6

Views: 1491

Answers (1)

Will Jones
Will Jones

Reputation: 2191

A bit late on this one, but in case anyone happens across it, I'll answer it anyway.

Managing PHP on MacOS with homebrew can be a bit of a pain, but it can be made easier.

I've answered this question in great detail here, but to summarise:

  • Remove what you currently have installed and any existing taps to PHP repositories.
  • Tap the shivammathur/php repository using brew tap shivammathur/php
  • Install the PHP version you're after (e.g. brew install shivammathur/php/[email protected])
  • Link it using brew link

The PHP versions available through that tap include pgsql if I'm not mistaken.

For other extensions:

  • Tap the extensions repository: brew tap shivammathur/extensions
  • Install the extension you need: e.g. brew install [email protected]

Upvotes: 1

Related Questions