Attempted to load class "DOMDocument" from the global namespace - php

Ok so i have set up a new symfony3 project using :
Vagrant----Virtualbox----PHP56----MYSQL55----UBUNTUTRUSTY64.
Everything was working correctly until i make a "composer update". I have this error message and i cannot do anything now
Attempted to load class "DOMDocument" from the global namespace
So i found some proposed solution like "install php-xml" but it is already installed with newest version.
Does anyone have a solution or guide me to the right direction to find one
Many thanks
Nico

Had the same issue with PHP 7.0.9, this worked:
sudo apt-get install php7.0-xml

You need to install the php-xml for your php version.
If you have php 5.6. you need to install php5.6-xml. It seems the newest version does not work for older versions.
sudo apt-get install php5.6-xml
sudo service apache2 restart

even sudo apt-get install php-xml works. it takes the current version.

Related

The Zip PHP extension is not installed. Please install it and try again. Laravel

I am trying to run:
laravel new test
However, I am getting this error:
I am on PHP 7.4.7 and Laravel 2.3.0 and ubunti 16.04
I ran this during the installation of PHP:
sudo apt-get install -y php7.4-{bcmath,bz2,intl,gd,mbstring,mysql,zip}
if this helps on what I have tried.
I am a beginner with Laravel and PHP, so please be gentle and clear with your explanations, thanks.
Thanks.
I faced the same problem. Use this command:
php -v
To check php version(for me it was 7.4.9) .Then:
sudo apt-get install php7.4-zip
It will solve your problem.
Please see this answer for more.
RuntimeException The Zip PHP extension is not installed

Installing Mongodb PHP Drivers on Ubuntu 18.04

I have installed mongodb on a new Ubuntu 18.04 server. I can access and work with the database through the command line, but cannot access it via PHP, and was wondering how other people have gotten it to work.
Following a new build of Ubuntu 18.04, and installation of LAMP, I ran:
sudo apt install mongodb-server php-pear php7.2-dev
sudo pecl install mongodb
I then added the mongodb.so extension to the php.ini file, and a phpinfo(); page shows mongodb as installed. So far so good.
If I browse to a test php page ($mongo=new Mongo();), the page fails to load though.
Through web searches, I find the https://github.com/alcaeus/mongo-php-adapter page come up a lot, and I have run the composer installation command there, but to no avail.
Installed versions are: Ubuntu 18.04.2 LTS; mongoDBv3.6.3; php 7.2.17; Apache 2.4.29
I was wondering what steps other people who have gotten PHP to work successfully with Mongodb have followed? I plan to scrap this server and start from a fresh VM install again.
I was able to install php-mongodb after adding the ppa repository ondrej/php:
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install php-mongodb
try:
sudo apt-get install php-mongodb
worked for me
It appears that you're attempting to use the Mongo class from the legacy driver, but you're using the non-legacy driver so that class doesn't exist. Please look at the documentation for the updated version of the driver here. You might also consider using the MongoDB PHP Library to abstract away many of the driver calls.
Please note that there are also compatibility considerations between your versions of the PHP library, MongoDB, and the MongoDB PHP driver. You can find the compatibility information for them here.

PHP: Cleanly upgrading/replacing PHP from unavailable repository on Ubuntu 12.04

I am running an Ubuntu 12.04 Apache2/PHP/MYSQL server that was using a deprecated version of PHP. I realized this once I tried to install the sqlite3 extension I get an error:
Failed to fetch http://ppa.launchpad.net/ondrej/php5-5.6/ubuntu/dists/precise/main/source/Sources
Research shows me that this is no longer used and instead use ondrej/php instead. This is a production server and I need to figure out steps to replace the PPA with the correct one.
Will I need to uninstall PHP and reinstall using the new packages? If so how should I go about doing this cleanly?
Is there a way to temporarily install sqlite3 without having to change repositories completely (I do not have php-dev installed at the moment either).
First you should check if there are any compatibility issues with the version you want to upgrade to (did a quick google to find this: https://github.com/squizlabs/PHP_CodeSniffer). Then, add the repository that contains the version you want, sudo apt-get update and install the version of php you want. To switch the version apache uses, do the following:
sudo a2dismod php5
sudo a2enmod php5.6
sudo service apache2 restart

Php7 Installation of wordpress on nginx throwing PHP installation missing MySQL extension which is required by WordPress

How can I fix this? im trying to do a clean install of wordpress latest on ubuntu 16 running nginx for Php7
When i access :
http://blog.mysite.com/wordpress/
I get:
Your PHP installation appears to be missing the MySQL extension which
is required by WordPress.
How can i resolve this?
Simply install necessary extensions and restart fpm process:
sudo apt-get install php-mysqlnd php-mysqli
sudo /etc/init.d/php7.0-fpm restart
This is a real relief I found this post, which helped me:
How to enable MySQLi extension in php 7?
Basically, if you're running php7 instead of php5 you should run this to resolve this issue:
sudo apt-get install php-mysql
and yes, as #Kris mentioned:
reload your webserver

How do I remove Dotdeb version of PHP and replace it with official Ubuntu repo

I'm a UBUNTU and CLI Noob.
I'm running UBUNT 12.04 LTS
I'm trying to get CURL to work for my PHP install and come to find out that PHPCURL does not work with the Dotdeb version of PHP that installed on my server.
Everything I've read so far says to remove the DOtdeb version of PHP and replace it with an official Ubuntu version however I'm not seing any clear instructions on this.
Is there an easy command to remove the Dotdeb version?
Should I just run sudo apt-get -y purge php*? I'm afraid that it will remove stuff I didn't intend to remove but I'm not sure.
Also, how do I know that the new PHP5 package I install is an official Ubuntu package?
First remove Dotdeb.org from your source list.
Next your need to uninstall php5
aptitude purge php5
Now run a simple update
aptitude update
Now reinstall php5
aptitude install php5
This really is the only way to go about it. You really need to do a purge, because simply removing it using normal uninstall does not get rid of the dotdeb config files that sometime remain.
You might just not have the php curl library installed. sudo apt-get install php5-curl will fix that.

Categories