1

I downloaded Respect/validation zip file from here https://github.com/Respect/Validation/archive/master.zip

I unzipped the archive and added a php file named phpinfo.php @ /Validation-master/Validation-master/library/

this is the project structure enter image description here

the contents of the phpinfo file is

<?php
use Respect\Validation\Validator as v;

$usernameValidator = v::alnum()->noWhitespace()->length(1,15);

$valid = $usernameValidator->validate("alganet"); //$valid now == true
$valid = $usernameValidator->validate("ácido acético"); //$valid now == false
?>

I have an XAMPP installation running. I tried running the phpinfo.php file from my browser.

I am getting the Fatal error: Class 'Respect\Validation\Validator' not found in C:\xampp\htdocs\phpproj\boots\Dropbox\EasyAccounts\validation\Validation-master\Validation-master\library\phpinfo.php on line 4

What should I do to load the class ? I am a newbie in terms of PHP.

Ananda
  • 888
  • 9
  • 19

1 Answers1

1

You should either include the file or use an autoloader

Maxim Krizhanovsky
  • 26,265
  • 5
  • 59
  • 89
  • What is the file that I should include? Also please let me know how to include a file that is in another directory? – Ananda Aug 13 '14 at 16:55
  • I tried auto loading but found it the hard way that it is a pain to do. Now I am going ahead with composer which is the recommended way of doing things. – Ananda Nov 19 '14 at 05:38