composer.json:
"autoload": {
"psr-4": {
"App\\": "src/"
}
},
src/Auth/RequestMethodPathRule.php:
namespace App\Auth;
class RequestMethodPathRule implements \Slim\Middleware\HttpBasicAuthentication\RuleInterface
{
...
src/middleware.php
$app->add(new \Slim\Middleware\HttpBasicAuthentication([
"rules" => [new App\Auth\RequestMethodPathRule(
This results in
Class 'App\Auth\RequestMethodPathRule' not found.
Including all of the code in RequestMethodPathRule.php in the file middleware.php works fine.
More strangely, along with the 500 error, the browser displays the source code of RequestMethodPathRule.php!
EDIT:
Oh my, I had a shorttag on the class file (<? instead of <?php)
so php treated it as text. Habits are hard to quit.