Php extensions dom enable

Install the PHP DOM Extension on CentOS – the Easiest Way

Here we cover the fastest, most effective way to get the PHP DOM extension installed on CentOS. If you’ve just found out you need to install this extension, but don’t really know what it is, we’ve included some background first.

What is DOM?

“The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents.” (Source: DOM in Wikipedia.)

What is PHP DOM extension?

“The DOM extension allows you to operate on XML documents through the DOM API with PHP 5.” (Source: Introduction to the PHP DOM Extension on php.net.)

How to install the PHP DOM Extension on CentOS

You will need superuser privileges. Run the following command:

Don’t forget to restart Apache so PHP picks up the new extension:

sudo service httpd restart

How to Check PHP DOM is Installed

You can see PHP DOM is installed by creating a simple web page that calls the phpinfo() function:

When you go to this webpage in a browser, you should see this output for the dom extension if it’s installed:

Читайте также:  Front end разработка javascript

dom

DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.26
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled

28 replies on “Install the PHP DOM Extension on CentOS – the Easiest Way”

Thanks! Every other resource I found on installing PHP DOM involved manually installing dependencies, recompiling PHP, etc. You just saved me a bunch of hassle. Apparently, the fact that you can simply do it with YUM is a well-kept secret.

Fritz, you are are very welcome! It’s lovely to get a thank you. 🙂

Thanks man, I was triing to install a php script, Get Simple CMS, and allthought simple xml was installed ( on a CentOs 5 with virtualmin ) the DOM API was not.
the simple

and apache restart, soved the problem.

Ty man looked and spended hours before i came to you site love you.

Veronica, you are so welcome! 🙂

To do this now, replace ‘php’ with ‘php53’ if you want PHP 5.3.x. There are serious conflicts between standard PHP (5.1.6 at the time of writing) and 5.3. I had to completely clean out php-common, php-mysql, etc and replace them with php53-common and so on.

Thank you for taking the time to post this info!

Are you using CentOS?
If so, which version?

There’s a small issue in your docu:

It must be:
sudo service httpd restart

I have tried this = yum install php-xml
and showing following errors, please help :
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* Webmin: webmin.mirror.somersettechsolutions.co.uk
* atomic: www7.atomicorp.com
* base: centos.vr-zone.com
* epel: http://ftp.cuhk.edu.hk
* extras: centos.vr-zone.com
* updates: centos.vr-zone.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package php-xml.i386 0:5.3.8-2.el5.art set to be updated
–> Processing Dependency: php-common = 5.3.8-2.el5.art for package: php-xml
–> Finished Dependency Resolution
php-xml-5.3.8-2.el5.art.i386 from atomic has depsolving problems
–> Missing Dependency: php-common = 5.3.8-2.el5.art is needed by package php-xml-5.3.8-2.el5.art.i386 (atomic)
Error: Missing Dependency: php-common = 5.3.8-2.el5.art is needed by package php-xml-5.3.8-2.el5.art.i386 (atomic)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.

Waiting for your response ASAP

sudo yum install php-common

php-common is already installed but i still cannot yum install php-xml
———————-
Setting up Install Process
Package matching php-common-5.1.6-27.el5_7.5.x86_64 already installed. Checking for update.
Nothing to do
————————

]# yum install php-xml
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: centos.vr-zone.com
* epel: mirror.nus.edu.sg
* extras: centos.vr-zone.com
* updates: centos.vr-zone.com
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package php-xml.x86_64 0:5.1.6-27.el5_7.5 set to be updated
–> Processing Dependency: php-common = 5.1.6-27.el5_7.5 for package: php-xml
–> Processing Dependency: libexslt.so.0()(64bit) for package: php-xml
–> Processing Dependency: libxslt.so.1()(64bit) for package: php-xml
–> Running transaction check
—> Package libxslt.x86_64 0:1.1.17-2.el5_2.2 set to be updated
—> Package php-xml.x86_64 0:5.1.6-27.el5_7.5 set to be updated
–> Processing Dependency: php-common = 5.1.6-27.el5_7.5 for package: php-xml
–> Finished Dependency Resolution
php-xml-5.1.6-27.el5_7.5.x86_64 from updates has depsolving problems
–> Missing Dependency: php-common = 5.1.6-27.el5_7.5 is needed by package php-xml-5.1.6-27.el5_7.5.x86_64 (updates)
Error: Missing Dependency: php-common = 5.1.6-27.el5_7.5 is needed by package php-xml-5.1.6-27.el5_7.5.x86_64 (updates)
You could try using –skip-broken to work around the problem
You could try running: package-cleanup –problems
package-cleanup –dupes
rpm -Va –nofiles –nodigest
The program package-cleanup is found in the yum-utils package.

Have the webtatic repo installed and do the following

sudo yum –enablerepo=webtatic install php-xml
service httpd stop
service httpd start

Thank you man. I saved a lot of time, and this is only thanks to you 🙂

You’re really welcome Cristian! 🙂

Источник

Why Can’t You Enable the PHP DOM Extension? Common Causes and Fixes

The PHP DOM (Document Object Model) Extension is an essential part of web development, enabling coders to manipulate and modify HTML and XML documents with PHP. However, there are times when developers can’t seem to enable the DOM extension. In this article, we’ll explore some common causes and fixes for this issue.

Check Your PHP Version

One of the most common reasons why developers can’t enable the PHP DOM extension is because they’re using an outdated version of PHP. The DOM extension requires at least PHP 5.0.0, so make sure you’re using an updated version of PHP. If you’re unsure which version you’re running, you can check by running this command in your terminal or command prompt:

This should give you the version number of PHP you’re currently using.

Check Your PHP Configuration File

If you’re sure that you’re running an updated version of PHP and still can’t enable the DOM extension, it’s possible that the extension isn’t listed in your php.ini configuration file. To check if it’s listed, run this command in your terminal or command prompt:

This should return a list of all the DOM-related extensions that are installed on your system. If the DOM extension isn’t listed, you’ll need to add it to your php.ini configuration file. To do this, open your php.ini file and add or uncomment this line:

Save the file and restart your PHP server to apply the changes.

Check Your PHP Environment

If you’ve checked your PHP version and configuration file, and the DOM extension is still not enabled, it could be due to a problem with your PHP environment. Check to see if your system has the necessary dependencies installed. Depending on your server setup, you may need to install additional packages to support the DOM extension.

For example, on Ubuntu, you can install the necessary packages using this command:

sudo apt-get install php-dom 

On other systems, you may need to download and install the necessary packages manually. Check your system’s documentation to see which packages are needed and how to install them.

Conclusion

The PHP DOM extension is a powerful tool that can help developers manage and modify HTML and XML documents with ease. However, if you can’t enable the extension, it can be frustrating. By following the tips outlined in this article, you can troubleshoot and fix common issues preventing you from enabling the PHP DOM extension. With the extension activated, you’ll be able to take your PHP development to new heights.

Источник

Оцените статью