Install php xml on mac

Apparently the Homebrew Package Manager decided to nuke support for PHP extensions. Regardless of my opinions or feelings about this decision, it’s necessary to figure out a way to get PHP and its extensions to work again WITHOUT USING MACPORTS. I have some standards.

The good news is that you can still install a base PHP 7.1 via Homebrew:brew install

#Uninstall the old Homebrew PHP 7.1
brew uninstall php71
brew install

Next, you’ll want to make sure your Mac is using this php homebrew version:

echo 'export PATH="/usr/local/opt//bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt//sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc

Make sure to use the appropriate .rc file: zshrc for z-shell, bashrc for bash, etc. I am obviously using z-shell.

Now if you run which php you should see:

/usr/local/opt//bin/php

Good. Now we have a shiny new PHP 7.1 with pecl available.

Next is to start installing extensions. I need to install the PHP memcache extension. Whereas I used to do brew install php71-memcache, we need to now use pecl instead:

pecl install memcached

Cool! I should be able to start up my PHP server and have the memcache extension available, right? It might work for you, which is awesome. Sadly, I was met with:

[exec] Warning: PHP Startup: Unable to load dynamic library '/usr/local/Cellar//7.1.16_1/lib/php/20160303/memcached.so' - dlopen(/usr/local/Cellar//7.1.16_1/lib/php/20160303/memcached.so, 9): image not found in Unknown on line 0

Balls. What is happening?

After some digging, I learned that even though I uninstalled homebrew’s old php71 and replaced it with (the post-nuke version), that didn’t remove the old /usr/local/etc/php/7.1 dir. So, old extension .ini files could be found in conf.d. My server was still trying to use them and thus raising errors. So, I had to do:

brew uninstall 
rm -rf /usr/local/etc/php/7.1
brew install
echo 'export PATH="/usr/local/opt//bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt//sbin:$PATH"' >> ~/.zshrc
pecl install memcached
#"yes" to libmemcached because why not? I have no idea what it is!

And there we go. It finally works again on my machine.

So if your approach to PHP 7.1 on Mac like “Homebrew for base PHP, pecl for all my extensions” you should be good to go, as long as you remove remnants of the previous Homebrew PHP 7.1.

This is probably the way it always should have worked. And the Homebrew team is right. But doesn’t it feel so much better to whine and kick and scream about a change, even if it’s for the better?

DISCLAIMER: I have no idea if this is the best way to do this. But it works on my machine. And that’s all I really care about.

Asked 9 years, 5 months ago

Viewed 6k times

Fatal error: Class 'DropDead\HomeBundle\Controller\DOMDocument' not found in ....

I need to install php-xml. I am using OS X. Cant find out how to install this extension.

Install php xml on mac

hakre

187k48 gold badges419 silver badges802 bronze badges

asked Apr 8, 2013 at 10:52

0

Are you sure, you're doing it right? the dom extensions usually is compiled by default.

It looks like you run into namespacing issues. Try

$foo = new \DomDocument();

instead of just DomDocument() and it should hopefully run.

answered Apr 8, 2013 at 11:08

3

Change language:

Submit a Pull Request Report a Bug

Table of Contents

  • Using Packages
  • Using the bundled PHP prior to macOS Monterey
  • Compiling PHP on macOS

This section contains notes and hints specific to installing PHP on macOS. PHP is bundled with macOS since macOS X (10.0.0) prior to macOS Monterey (12.0.0). Compiling is similar to the Unix installation guide.

+add a note

User Contributed Notes

There are no user contributed notes for this page.

Can you install PHP on Mac?

PHP is bundled with macOS since macOS X (10.0. 0) prior to macOS Monterey (12.0. 0). Compiling is similar to the Unix installation guide.

How do I enable PHP extensions on Mac?

HowTo: Installing ffmpeg-php extension for MAMP (Mac).
First of all point your php and phpize to your MAMP environment. ... .
Install ffmpeg (required by PHP ffmpeg.so extension) ... .
Install ImageMagick (required by PHP ffmpeg.so extension) ... .
If you want to install Imagick manually. ... .
Configure your php.ini. ... .
Restart your Apache..

How do I know if PHP

You can use the command line switch -m to php to see what modules are installed. $ php -m | head [PHP Modules] bz2 calendar ctype curl date dbase dom exif fileinfo ... You could also use php -i to get phpinfo(); output via the command line which would include this info as well.

Where is PHP installed Mac?

Set the php. ini location or use the default A typical default location on macOS is /usr/local/php/php.