1

It seems like that the Validator::make($input, $rules) is not working when I try to validate the request. The added prefix of "\" makes the job done.

What is the reason behind this mark use since lots of the documentation and lectures don't make use of it?

Aashish K
  • 103
  • 2
  • 12

2 Answers2

3

The slash "\" is a way to say to PHP that the class is in the Global Namespace.

If you don't use the "\" in front of your Class, then you need to declare it first using the "use" keyword.

In your case, on top of your file :

use Validator;

You can look at this other StackOverlow post : https://stackoverflow.com/a/4790031/9291504

0

You want to interest about PHP Namespaces. If you are in another namespace you want firstly go to the root namespace by \ symbol. after you can use your preferred namespace.