So I'm using Simfatic\FormHandler
to create a simple form that sends out an email, tested locally all works fine.
I put the stuff on Hostinger and all of a sudden it's saying it can't find CommonValidations
, even though it's part of the package.
require(__DIR__.'/vendor/autoload.php');
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use Simfatic\FormHandler\FormHandler;
use PHPMailer\PHPMailer\PHPMailer;
use Dotenv\Dotenv;
$form = new FormHandler();
$dotenv = Dotenv::createMutable(__DIR__);
$dotenv->load();
$form->validate(function($validator) {
$validator->field('email')->isEmail()->isRequired();
$validator->field('fullname')->isRequired();
$validator->field('jobtitle')->isRequired();
$validator->field('phonenumber')->isRequired();
$validator->field('postcode')->isRequired();
$validator->field('services')->isRequired();
$validator->field('info')->isRequired();
$validator->field('companyname')->isRequired();
})->configMailer(function($mailer) {
$mailer->setFrom($_POST['email'], $_POST['fullname'], false);
$mailer->isSMTP();
$mailer->SMTPDebug = true;
$mailer->SMTPAuth = true;
$mailer->Port = $_ENV['PORT'];
$mailer->Host = $_ENV['HOST'];
$mailer->Username = $_ENV['EMAIL'];
$mailer->Password = $_ENV['PWD'];
$mailer->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS;
$mailer->isHTML(true);
$mailer->Body = "Body Goes Here";
$mailer->Subject = "Inquiry form submission from {$_POST['fullname']} @ {$_POST['companyname']}";
})->sendEmailTo($_ENV['EMAIL']);
echo $form->process($_POST);
The error in question:
"Simfatic\Boar\Library\CommonValidations" not found in public_html/vendor/simfatic/boar/src/Boar.php:13 Stack trace: #0 public_html/vendor/simfatic/boar/src/Boar.php(18): Simfatic\Boar\Boar->__construct() #1 public_html/vendor/simfatic/formhandler/src/FormHandler.php(39): Simfatic\Boar\Boar::create() #2 public_html/mail.php(12): Simfatic\FormHandler\FormHandler->__construct() #3 {main} thrown in public_html/vendor/simfatic/boar/src/Boar.php on line 13
I've tried clearing and reinstalling the packages with composer as well as contacting the owner of the repo and raising an issue. Any advice on how to debug it would be greatly appreciated.
There's a bug in the simfatic/boar
package. PSR-4 class autoloading mandates that your directories and files are named after the namespace + class names, but the Library/Validator
namespace is using lowercase directory names:
This works in filesystems that do not distinguish case (e.g. NTFS on Windows) but fails otherwise because it isn't fully correct.
As a workaround, you can create symlinks with the correct names (if you have SSH access to your account) or rename the directories after the upload. Changing case in your local Windows computer is also possible, but you'll need to do it in two steps: library
-> Library_
-> Library
.
This workaround will break if you reinstall or upgrade the package.
Alternatively, report it as bug and/or submit a pull request with a fix.