Het volgende heb ik aan de hand.
Ik probeer een class statisch te gebruiken in een andere class.
Nu krijg ik een error dat de class niet gevonden word.
Uncaught Error: Class 'app\controllers\Application' not found in /Applications/MAMP/htdocs/website/app/controllers/SiteController.php
<?php
namespace app\controllers;
class SiteController
{
public function contact()
{
return Application::$app->render('contact');
}
}
?>
<?php
namespace app\core;
class Application
{
public static Application $app;
public function __construct()
{
self::$app = $this;
}
public function render($view){
}
}
?>
Zodra ik de namespace van SiteController verander naar app\core en de file in de core directory zet word deze wel gevonden.
Er gaat dus iets mis met de autoloader vermoed ik. Iemand een idee hoe ik dit kan oplossen?
toevoeging
<?php
return app\core\Application::class;
?>
Geeft resultaat app\controllers\app\core\Application