Php install dom module

LitePublisher requires «domDocument» class and domxml extension

При установке популярной CMS LitePublisher получил следующую ошибку в окне браузера LitePublisher requires «domDocument» class and domxml extension. Видимо я первый кто с этим столкнулся, потому что на официальном сайте ответа не нашел.

Легкий поиск в сети привел к понимаю, что не хватает PHP модулей для работы с XML, так называемое расширение PHP DOM.

Что такое DOM

DOM (от англ. Document Object Model — «объектная модель документа») — это не зависящий от платформы и языка программный интерфейс, позволяющий программам и скриптам получить доступ к содержимому HTML, XHTML и XML-документов, а также изменять содержимое, структуру и оформление таких документов.
Взято из Википедии

Что такое раширение PHP DOM

Расширение DOM позволяет вам работать с XML-документами через DOM API с PHP 5.
Взято из php.net

Как установить расширение PHP DOM Extension в CentOS

Решение для CentOS выглядит следующим образом:

Читайте также:  Not Found

По окончании необходимо перезагрузить Apache:

После этого установка CMS LightPublisher пошла в штатном режиме.

Как проверить что раширение PHP DOM установлено

Создайте простенький файл, к примеру phpinfo.php со следующим содержимым:

Затем зайдите браузером на эту страницу http://mysitename/phpinfo.php. Если все хорошо, то вы должны увидеть примерно следующее:

Список использованных источников

Источник

How to Install ext-dom PHP 7.2 on Ubuntu, Windows, CentOS, and RHEL

Learn how to install the ext-dom PHP 7.2 extension on Ubuntu, Windows, CentOS, and RHEL with helpful tips for optimizing PHP code and best practices for PHP development.

  • Installing ext-dom on Ubuntu
  • Installing ext-dom on Windows
  • Installing PHP extensions on CentOS and RHEL
  • Tips for optimizing PHP code
  • Best practices for PHP development
  • Other quick examples for installing ext-dom PHP 7.2
  • Conclusion
  • How do I install the PHP DOM extension on CentOS?
  • Is PHP DOM extension enabled by default on Ubuntu 20?
  • How to install the Ext-curl extension with PHP 7?
  • How to install a PHP extension on Windows?

PHP is a widely-used server-side scripting language used for creating dynamic web pages and applications. It is known for its flexibility, ease-of-use, and ability to integrate with other languages. PHP has a vast array of extensions, which are libraries that can be added to PHP to enhance its capabilities. One such extension is ext-dom PHP 7.2, a commonly used extension for manipulating XML documents. In this article, we’ll discuss how to install the ext-dom PHP 7.2 extension on Ubuntu and Windows, as well as provide helpful tips for optimizing php code and best practices for php development .

Installing ext-dom on Ubuntu

Ubuntu is a popular Linux distribution widely used for web and application development. Installing ext-dom PHP 7.2 on Ubuntu is straightforward. The following steps outline the installation process:

  1. Open the terminal by pressing Ctrl+Alt+T on your keyboard.
  2. Type the following command to install the PHP-XML package:
sudo apt-get install php7.2-xml 
sudo apt-get install php-mbstring 
sudo systemctl restart apache2 

Installing ext-dom on Windows

Installing ext-dom PHP 7.2 on Windows is a little different from installing it on Ubuntu. The following steps outline the installation process:

  1. Download the pre-compiled extension from https://windows.php.net/downloads/pecl/releases/dom/ .
  2. Extract the downloaded file and copy the php_dom.dll file to your PHP extensions directory. This directory is usually located at C:\php\ext .
  3. Open your PHP configuration file php.ini , which is usually located at C:\php\php.ini , and add the following line to the end of the file:

Installing PHP extensions on CentOS and RHEL

CentOS and RHEL are popular Linux distributions used for web and application development. The process of installing ext-dom PHP 7.2 on CentOS and RHEL is similar to that of Ubuntu. Here are the steps:

  1. Open the terminal by pressing Ctrl+Alt+T on your keyboard.
  2. Type the following command to install the PHP-XML package:
sudo systemctl restart httpd 

Tips for optimizing PHP code

PHP code can be optimized to improve performance and reduce load times. Here are some tips:

  1. Use a caching mechanism: Caching can significantly improve PHP code performance . There are several caching mechanisms available, such as APC, Redis, and Memcached.
  2. Minimize database queries: Minimizing database queries can also improve performance. You can achieve this by using caching mechanisms or optimizing your SQL queries.
  3. Use a content delivery network (CDN): Using a CDN for static assets can speed up page load times. A CDN is a network of servers located around the world that can serve static assets such as images, CSS, and JavaScript files.
  4. Use a PHP cheatsheet: A PHP cheatsheet can help developers quickly reference php syntax and functions . Cheatsheets are available online for free and can be downloaded for offline use.

Best practices for PHP development

Following best practices can make your PHP code more organized, maintainable, and secure. Here are some best practices to follow:

  1. Use object-oriented programming : Object-oriented programming can make your code more organized and maintainable. It allows you to encapsulate data and behavior into classes, making your code easier to understand and modify.
  2. Write clean and maintainable code : Writing clean and maintainable code can save time and prevent errors. Use meaningful variable names, avoid global variables , and follow a consistent coding style.
  3. Follow secure coding practices : Follow secure coding practices to prevent security vulnerabilities such as SQL injection, cross-site scripting (XSS), and cross-site request forgery (CSRF). Use prepared statements for database queries , sanitize user input, and validate user input on the server-side.
  4. Learn other programming languages: Popular programming languages for web development other than PHP include Python, Ruby, and JavaScript. Learning other languages can broaden your skills and make you a more versatile developer.

Other quick examples for installing ext-dom PHP 7.2

In Php , in particular, Install ext-dom php 7.2 code example

sudo apt-get update sudo apt-get install php7.2-xml

Conclusion

Installing the ext-dom PHP 7.2 extension can be done easily using various commands on Ubuntu, CentOS, RHEL, and Windows. Restarting Apache after installing a new extension is necessary for PHP to pick up the changes. Optimizing PHP code and following best practices can improve performance and prevent errors and security vulnerabilities. Other popular programming languages for web development include Python, Ruby, and JavaScript. By following the steps outlined in this article, you can install the ext-dom PHP 7.2 extension and start manipulating XML documents in your PHP code.

Источник

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:

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! 🙂

Источник

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