• Dear Pleskians! The Plesk Forum will be undergoing scheduled maintenance on Monday, 7th of July, at 9:00 AM UTC. The expected maintenance window is 2 hours.
    Thank you in advance for your patience and understanding on the matter.

Resolved Problems loading Composer autoload.php

cloudNiner

New Pleskian
Server operating system version
Ubuntu 22.04
Plesk version and microupdate number
18.0.63 #4
I have migrated my site from a shared server to a Plesk-managed VPS and am trying to get my php scripts using PHPMailer to work. I installed PHPMailer using Composer from a shell, following articles on how to use it with Plesk. My problem is getting the Composer-generated autoload to work:
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require '/root/vendor/autoload.php';

Composer installed autoload in /root/vendor, which might be the problem. Should it go elsewhere? After turning off open_basedir and adding /root/vendor to the include path, I get this in error_log:
PHP Warning: require(/root/vendor/autoload.php): Failed to open stream: Permission denied in /var/www/vhosts/photomungus.com/httpdocs/registrationForm.php on line 15; PHP message: PHP Fatal error: Uncaught Error: Failed opening required '/root/vendor/autoload.php' (include_path='.:/opt/plesk/php/8.3/share/pear; /root/vendor') .

What is the right way to do it?
 
I got this to work by running Composer from my project directory. It places the files in the location from which you invoke it.
 
Back
Top