PHP Fatal error: Uncaught Error: Interface ‘Authentication\AuthenticationServiceProviderInterface’ not found in /var/www/src/Application.php:48
Stack trace:
#0 /var/www/vendor/composer/ClassLoader.php(480): include()
#1 /var/www/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile()
#2 [internal function]: Composer\Autoload\ClassLoader->loadClass()
#3 /var/www/bin/cake.php(11): spl_autoload_call()
#4 {main}
thrown in /var/www/src/Application.php on line 48
→ below the code in Application.php looks like this:
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.3.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace App;
use Cake\Core\Configure;
use Cake\Core\Exception\MissingPluginException;
use Cake\Error\Middleware\ErrorHandlerMiddleware;
use Cake\Http\BaseApplication;
use Cake\Http\Middleware\BodyParserMiddleware;
use Cake\Http\Middleware\CsrfProtectionMiddleware;
use Cake\Routing\Middleware\AssetMiddleware;
use Cake\Routing\Middleware\RoutingMiddleware;
use Authentication\AuthenticationService;
use Authentication\AuthenticationServiceInterface;
use Authentication\AuthenticationServiceProviderInterface;
use Authentication\Middleware\AuthenticationMiddleware;
use Cake\Http\MiddlewareQueue;
use Connehito\CakeSentry\Plugin;
use Psr\Http\Message\ServerRequestInterface;
use App\Command\promoteUserToEventCommand;
use App\Command\markOrderAsPaidCommand;
use App\Command\removeOrderCommand;
use Cake\Command\VersionCommand;
use Cake\Console\CommandCollection;
use function Sentry\init;
//use App\Command\promoteUserToEventCommand;
//use App\Command\markOrderAsPaidCommand;
//use App\Command\removeOrderCommand;
//use Cake\Command\VersionCommand;
//use Cake\Console\CommandCollection;
/**
* Application setup class.
*
* This defines the bootstrapping logic and middleware layers you
* want to use in your application.
*/
class Application extends BaseApplication implements AuthenticationServiceProviderInterface
{
/**
* {@inheritDoc}
*/
public function bootstrap(): void
{
// Call parent to load bootstrap from files.
parent::bootstrap();
if (PHP_SAPI === 'cli') {
$this->bootstrapCli();
}
/*
* Only try to load DebugKit in development mode
* Debug Kit should not be installed on a production system
*/
if (Configure::read('debug')) {
$this->addPlugin('DebugKit');
}
$this->addPlugin('Authentication');
if(env('SENTRY')){
init(Configure::read('Sentry'));
}
}
public function console(CommandCollection $commands): CommandCollection
{
$commands->add('promoteUserToEventCommand', new promoteUserToEventCommand());
$commands->add('markOrderAsPaidCommand', new markOrderAsPaidCommand());
$commands->add('removeOrderCommand', new removeOrderCommand());
// return parent::console($commands); // TODO: Change the autogenerated stub
return $commands;
}
/**
* Setup the middleware queue your application will use.
*
* @param \Cake\Http\MiddlewareQueue $middlewareQueue The middleware queue to setup.
* @return \Cake\Http\MiddlewareQueue The updated middleware queue.
*/
public function middleware($middlewareQueue): MiddlewareQueue
{
$middlewareQueue
// Catch any exceptions in the lower layers,
// and make an error page/response
->add(ErrorHandlerMiddleware::class)
// Handle plugin/theme assets like CakePHP normally does.
->add(new AssetMiddleware([
'cacheTime' => Configure::read('Asset.cacheTime')
]))
// Add routing middleware.
// Routes collection cache enabled by default, to disable route caching
// pass null as cacheConfig, example: `new RoutingMiddleware($this)`
// you might want to disable this cache in case your routing is extremely simple
->add(new RoutingMiddleware($this, '_cake_routes_'))
->add(new AuthenticationMiddleware($this))
->add(new BodyParserMiddleware())
// Add csrf middleware.
// ->add(new CsrfProtectionMiddleware([
// 'httpOnly' => true
// ]))
// Add CORS for development environments.
// ->add(function($request, $response, $next) {
// return $next($request, $response)
// ->withHeader('Access-Control-Allow-Origin', env('FRONTEND_URL', 'https://members.strippenkaart.app'))
// ->withHeader('Access-Control-Allow-Methods', '*')
// ->withHeader('Access-Control-Allow-Credentials', 'true')
// ->withHeader('Access-Control-Allow-Headers', 'X-Requested-With')
// ->withHeader('Access-Control-Allow-Headers', 'Content-Type')
// ->withHeader('Access-Control-Allow-Headers', 'Accept')
// ->withHeader('Access-Control-Allow-Type', 'application/json');
// })
;
return $middlewareQueue;
}
/**
* Bootstrapping for CLI application.
*
* That is when running commands.
*
* @return void
*/
protected function bootstrapCli(): void
{
try {
$this->addPlugin('Bake');
} catch (MissingPluginException $e) {
// Do not halt if the plugin is missing
}
$this->addPlugin('Migrations');
// Load more plugins here
}
/**
* @inheritDoc
*/
public function getAuthenticationService(ServerRequestInterface $request): AuthenticationServiceInterface
{
$service = new AuthenticationService();
$fields = [
'username' => 'email',
'password' => 'password'
];
// Unauthenticated Redirect * J *
$service->setConfig([
'unauthenticatedRedirect' => '/users/login',
'queryParam' => 'redirect',
]);
// Load the authenticators, you want session first
$service->loadAuthenticator('Authentication.Form', [
'fields' => $fields,
]);
$service->loadAuthenticator('Authentication.Jwt', [
'returnPayload' => false,
]);
// Load identifiers
$service->loadIdentifier('Authentication.Password', [
'fields' => $fields,
]);
$service->loadIdentifier('Authentication.JwtSubject', [
'tokenField' => 'id',
'dataField' => 'sub',
]);
return $service;
}
}