Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class 'SimpleXMLElement' not found #1598

Closed
koushikSen opened this issue Aug 14, 2018 · 15 comments
Closed

Class 'SimpleXMLElement' not found #1598

koushikSen opened this issue Aug 14, 2018 · 15 comments

Comments

@koushikSen
Copy link

Hi, My project is in EC2, upon delete any s3 file I am having this error.
(1/1) FatalThrowableError Class 'SimpleXMLElement' not found

I have PHP 7.2 and XML and SimpleXML both installed in EC2. my local server does not throw this error while deleting from s3

@howardlopez howardlopez added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Aug 14, 2018
@diehlaws
Copy link
Contributor

Hey @koushikSen, thanks for reaching out about this. Just to rule out simple environment misconfigurations, can you check the phpinfo() output on your EC2 instance to ensure that the XML and SimpleXML packages are installed and enabled? If you've checked that they are, we'll need more information to troubleshoot this - a code sample would be ideal so we can try reproducing this behavior on our end.

@diehlaws diehlaws added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 14, 2018
@koushikSen
Copy link
Author

koushikSen commented Aug 16, 2018

screenshot from 2018-08-16 10-34-42

Yes, they are enabled.
Here is the codebase::

<?php public function delete($memory_id)
{
	$memory = new Memory();
	$qaMemory = new MemoryAccess;		
	$memoryInfo = $memory->where('memory_id',$memory_id)->first();
	$qaMemory->where('user_id',Auth::user()->id)->where('memory_recall_datetime',$memoryInfo->recall_date)->first();
	$qaMemory->delete();
	if($memoryInfo->mime_type){
		$path = $memoryInfo->memory_content;
		$pathArray = explode('/', $path);
		if(Storage::disk('s3')->exists(end($pathArray))){ // error occoured
			$isDeleted =  Storage::disk('s3')->delete(end($pathArray));
		} else{
	        	//echo "not found";
	        }
	}
	$memory->delete();
	return redirect('home')->with('registration_success', 'Registration successful');
} ?>

@diehlaws diehlaws removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Aug 16, 2018
@diehlaws
Copy link
Contributor

Thanks for the additional info. Just to rule out your local environment as the culprit, could you try running the following sample code that uses the SimpleXML package to see if you continue to receive this error? You may be running multiple PHP builds with different packages between CLI and web on this machine.

<?php
$string = <<<XML
<?xml version='1.0'?> 
<document>
 <title>TestTitle</title>
 <body>
  Here is some text
 </body>
</document>
XML;

$xml = simplexml_load_string($string);

print_r($xml);
?>

@koushikSen
Copy link
Author

in EC2 server :
ec2

In My localserver
local

Displaying simple array working fine in EC2, but displaying SimpleXML is when an error occurred.
thrown in /var/www/html/xml.php on line 12 [17-Aug-2018 04:29:41 UTC] PHP Fatal error: Uncaught Error: Call to undefined function simplexml_load_string() in /var/www/html/xml.php:12

@kstich
Copy link
Contributor

kstich commented Aug 20, 2018

It looks like your SimpleXML extension isn't hooked up properly to your PHP install on your EC2 server. I'd recommend searching on or asking a question on StackOverflow or opening a support ticket with AWS Support to help troubleshoot this issue.

@kstich kstich closed this as completed Aug 20, 2018
@diehlaws diehlaws removed the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Sep 15, 2018
@dalisay
Copy link

dalisay commented Oct 18, 2018

I encountered this same issue and restarting php-fpm resolved it.

sudo systemctl restart php-fpm

@skaiteo
Copy link

skaiteo commented Mar 16, 2019

Woah thanks @dalisay!! Can't believe that solved my issue!

@edmarola
Copy link

dalisay is my hero

@guri-dev
Copy link

@dalisay You are awesome.

@timothymarois
Copy link

Can someone please explain why @dalisay sudo systemctl restart php-fpm would solve this issue? The XML mod is installed, restarting apache doesn't solve it either, but fpm does? This is the first I've seen this, on AMI1 this was not an issue, only found on AMI2 instances with EC2.

@nhvaishnani
Copy link

Getting same error and as @dalisay said to run sudo systemctl restart php-fpm but in my terminal it's showing service not found.

@hongquan95
Copy link

Thanks @dalisay solution 👍

@skfaisal93
Copy link

Running sudo systemctl restart php-fpm command get me following error

Failed to restart php-fpm.service: Unit php-fpm.service not found.

I am using php 8 ubuntu 20.04

@xyz70941
Copy link

I have same issue,
I am using php 8 ubuntu 20.04

@BoyCoded
Copy link

BoyCoded commented Dec 29, 2023

For anyone getting this error: Failed to restart php-fpm.service: Unit php-fpm.service not found.

Run sudo systemctl restart php8.1-fpm for PHP 8.1 or replace the version with the one you installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests