getting this error
Notice: Undefined variable: response in F:\xampp\xxampp\htdocs\RESTAPI\test\middleware.php on line 12
Fatal error: Call to a member function write() on null in F:\xampp\xxampp\htdocs\RESTAPI\test\middleware.php on line 12
//this middleware class
<?php
namespace middleware;
/**
* middleware
*/
class guestMiddleware
{
public function __invoke($Request, $Response, $next)
{
$response->write("less");
$response = $next($request, $response);
$response->write("less");
return $response;
}
}
?>
To add a bit on what @tflight said, note that while variables are case sensitive, functions and classes (not objects when used as variables, careful) are case insensitive.
Constants are case sensitive by default but take a look at this :
It’s from the PHP manual. You may define constants as case insensitive, if you’d like.
This is just a heads up. I’ve had quite a bit of headache from peculiarity in the language. The problem you’ve had here is a consequence of this language specific.