I am getting the error message
Class ‘Uniform\Form’ not found
When trying to access my contact page with a Form generated with the Uniform plugin on my remote server. Strangely, everything else is working fine on the server, so my .htaccess doesn’t seem to be totally flawed.
When running locally via Mamp, everything is fine.
I am running the page in a subdirectory on the server but the domain is root.
The error occurs on the controller file, which is located here, according to the debugger:
/homepages/41/d76271265/htdocs/sh_kirby/site/controllers/contact.php
I am not even sure were to start investigating, so I thought I’d try with a really detailed error description (irony).
Thanks for the help in advance.
I guess you’ve already double checked that all files have been transmitted to the server correctly and completely!?
If all files are there, what about the file permissions? Are the uniform files and folders readable? Sometimes permissions get messed up by the server.
Files are all there, yes.
Permissions are drwx—r-x and -rwx—r-x for folders and files respectively, for the controller file and the whole Uniform plugin Folders and Subfolders. I don’t fully understand what that means but they are the same for all the other files.
I just pushed the htaccess again to make sure it is up to date. I also updated Uniform (Error encountered before and after). This is the htaccess content:
RewriteEngine on
RewriteBase /
RewriteRule ^content/(.).(txt|md|mdown)$ index.php [L]
RewriteRule ^site/(.) index.php [L]
RewriteRule ^kirby/(.) index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.) panel/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]
Am I right in assuming that somehow the files aren’t found, or is there another possible cause you can think of?
Is the folder called uniform inside /site/plugins
, i.e. does your structure look like this:
site/
plugins/
uniform/
uniform.php
If so, could you please post the code of your controller?
The folder is capitalized /site/plugin/Uniform/uniform.php
changing it to lowercase yields:
Whoops \ Exception \ ErrorException (E_PARSE)
syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’
So I changed it back to Uppercase.
Controller Code:
<?php
use Uniform\Form;
return function ($site, $pages, $page) {
$form = new Form([
'surname' => [
'rules' => ['required', 'alpha'],
'message' => 'Bitte geben Sie ihren vollständigen Namen an.',
],
'forename' => [
'rules' => ['required', 'alpha'],
'message' => 'Bitte geben Sie ihren vollständigen Namen an.',
],
'email' => [
'rules' => ['required', 'email'],
'message' => 'Bitte geben Sie eine gültige Email-Adresse an.',
],
'phone' => [
'rules' => ['required', 'num'],
'message' => 'Bitte geben Sie eine gültige Telefonnummer an.',
],
'message' => [
'rules' => ['required', 'max' => '5000'],
'message' => ['Bitte geben Sie eine Nachricht mit maximal 5000 Zeichen an.']
],
]);
if (r::is('POST')) {
$form->emailAction([
'to' => page('contact')->formadress(),
'from' => '',
'subject'=> '',
]);
}
return compact('form');
};
?>
The folder name should be lowercase (uniform), although I don’t know where the Exception comes from; doesn’t it give you any information where that error is thrown? And the parent folder name must be plugins not plugin, but maybe that is just a typo?
What PHP version are you using on the remote server?
1 Like
Well, you solved it, thanks:
PHP version was defaulted to 5.4 because of ‘extended support’, I guess.
I just switched to 7.1 AND named the folder /uniform, which worked.
Wierdly, I just tested it locally with both PHP versions and there was no problem naming the folder /Uniform or /uniform with 7.1, but the same Exception for both upper and lower case and PHP 5.4.
For the sake of completeness:
Remote, with the folder being /uniform (lowercase), the debugger yields:
/homepages/41/d76271265/htdocs/sh_kirby/site/plugins/uniform/uniform.php
<?php
use Uniform\Form;
// This file is called by Kirby if Uniform wasn't installed with Composer. In this case,
// use it's own vendor directory and autoload script.
if (!class_exists(Form::class)) {
require __DIR__.DS.'vendor'.DS.'autoload.php';
}
With /Uniform (Uppercase) as the folder it yields the controller as the source.
Thank you and good night!
Don’t know what OS you use locally, Windows isn’t case sensitive, while Unix-like systems are usually. Glad it works now and good night .