I am create file in webroot and included DefaultPasswordHasher.php but not working

i am create file in webroot and included DefaultPasswordHasher.php but not working


require CAKE."/Auth/DefaultPasswordHasher.php"; 

$conn = new mysqli($servername, $username, $password,$dbname);
		// Check connection
		if ($conn->connect_error) {
		  die("Connection failed: " . $conn->connect_error);
		}
		echo "Connected successfully";


		$stmt = $con->prepare("SELECT * FROM `users` WHERE `email` = ?");
		$username = $_POST['email'];
		$stmt->bind_param("s", $username);
		$stmt->execute();
		$result = $stmt->get_result();

		if ($result->num_rows == 0) { // User doesn't exist
			return false;
		   echo"No such username registered";
		  
		} else { // User exists

		    $row = $result->fetch_assoc();

		    if ((new DefaultPasswordHasher)->check($password,  $row['password'])) {
		     
		        return true;
		    } else {
		     	return false;
		    }
		}

Fatal error : Uncaught Error: Undefined constant “CAKE” in F:\app.jw-app.com\webroot\webapi.php:3 Stack trace: #0 {main} thrown in F:\app.jw-app.com\webroot\webapi.php on line 3

I suggest starting here and read about cake’s connections: Database

You don’t understand my problem, I want just import vendor folder in webapi.php file

The CAKE constant is not defined just like the error says so either use

  • an absolute path specific to your system or
  • a relative path

But I’d rather discourage you from building a API this way and instead make a Cake controller which you manually connect to a route and inside that controller action you can then leverage evertyhing Cake has to offer.

Okay then Why I am not allow method from outside cakephp already set cors but get cors errors so I am doing this way.