Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Class 'SimpleXMLElement' not found on puphpet PHP 7.0

PHP Fatal error: Uncaught Error: Class 'SimpleXMLElement' not found in /var/www/html/vendor/aws/aws-sdk-php/src/Api/Parser/PayloadParserTrait.php:39


The problem was that I was using Cent OS and in this Linux Distribution, the php-libxml package does not come as default.

I ended up generating a new machine through PuPHPet GUI and added to the System Package the following packages to be installed:

php-xml, php-simplexml
Problem solved.

For those using PHP 7 and Ubuntu, @MPS solved it by running "apt-get install php7.0-xml" and "service apache2 restart".

On Centos, we need to install the XML php package. You can try "yum install php56w-xml" or "yum install php70w-xml" if you're using php70w repository for PHP 7.0

How to change maximum file upload size for PHP applications

Find the php.ini file. In amazon ec2 linux instance, you can find in "/etc/php/7.0 (your version may vary)/apache2/" folder. Remember it varies from system to system.

On mac, it is at "/private/etc"

post_max_size = 2M
upload_max_filesize = 2M

Change the above two values to your desired value in MB. And restart the apache post update.

sudo service apache2 restart

Or

sudo /usr/sbin/apachectl graceful

AWS HTTP error: Client error: `POST https://s3.amazonaws.com/[…]` resulted in a `400 Bad Request` response: InvalidRequestYou must specify at least one part

S3 PHP SDK V3 COMPLETEMULTIPARTUPLOAD ERROR USING LOW LEVEL API OR COMING FROM V2 SDK

If you’re upgrading from the v2 to v3 SDK or following the low level API documentation for Multipart uploads such as http://docs.aws.amazon.com/AmazonS3/latest/dev/LLuploadFilePHP.html you will run into an impassable error. I ran into this problem while working on adding the new S3 SDK into BackupBuddy.

The Error:

Error executing “CompleteMultipartUpload” on “https://s3.amazonaws.com/[…]”; AWS HTTP error: Client error: `POST https://s3.amazonaws.com/[…]` resulted in a `400 Bad Request` response: InvalidRequestYou must specify at least one part
The problem is that the CompleteMultipartUpload function parameters have changed but Amazon has not updated their documentation properly and it is missing from their migration guide.

Solution:

The “Parts” parameter now needs to be placed in a new array named “MultipartUpload”.
Incorrect parameters (as per documentation or v2 SDK):
$result = $s3->completeMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $key,
'UploadId' => $uploadId,
'Parts' => $parts,
));
Correct parameters for v3 SDK:
$result = $s3->completeMultipartUpload(array(
'Bucket' => $bucket,
'Key' => $key,
'UploadId' => $uploadId,
'MultipartUpload' => array(
'Parts' => $parts,
),
));
Credits: http://dustinbolton.com/s3-php-sdk-v3-completemultipartupload-error-using-low-level-api-or-coming-from-v2-sdk/

Running PHP on the macOS / Mac OS X Apache Web Server

PHP 5 is installed in macOS / OS X by default, but the built-in Apache web server may not be configured to automatically run PHP. To enable PHP, the apache configuration file needs to be modified. This file is located in the following location: 

/etc/apache2/httpd.conf 

In order to edit this file, the permissions on the file must be changed. This can be accomplished by doing the following: 

1. Open a terminal windows (Applications -> Utilities -> Terminal) 

2. Change to the correct directory (cd /etc/apache2) 

3. Change the permissions on the file (sudo chmod 755 httpd.conf)
Once the file permissions are changed, you can use a tool like EditRocket to open the httpd.conf file and modify it. After opening the httpd.conf file, we need to look for the following line: 

#LoadModule php5_module libexec/apache2/libphp5.so 

This line needs to be uncommented by removing the # in front of the line. Remove the # and then save the file.
PHP is now enabled, but we need to restart the apache web server for the changes to take effect. To restart the web server, do the following:

sudo apachectl restart
This will restart the apache server. To test PHP, create a PHP file called test.php in the following directory.
/Library/WebServer/Documents/ 

Enter the following URL to visit the page: 

http://localhost/test.php

Installing PHP5 and Apache on Ubuntu

From a command shell, you will run the following commands:
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install libapache2-mod-php5
sudo /etc/init.d/apache2 restart
Note that if apache is already installed you can omit the first line. Your web files will now be found in /var/www/