No route defined / 404 – Page not found

ttrepper
Member | 11
+
0
-

Hi all, I apologize for the inconvenience but somethow I don't get the routing – I cannot get it up and running. I guess there is a small issue but I don't find it. Any help appreciated. Thank you very much in advance. 😃

My setup is:

Folder
\index.php
\app\Bootstrap.php
\app\Modules\Front\Web\DefaultPresenter.php
\config\application.neon

in index I load the bootstrap:

App\Bootstrap::boot()
	->createContainer()
	->getByType(Nette\Application\Application::class)
	->run();

in Bootstrap I do:

class Bootstrap {

	public static function boot() : Configurator {

        $appDir = dirname(__DIR__);

		$configurator = new Configurator;
		$configurator->setDebugMode(true);		//$configurator->setDebugMode('secret@23.75.345.200');
		$configurator->enableTracy($appDir . '/logs');
		$configurator->setTempDirectory($appDir . '/temp');
		$configurator->createRobotLoader()
			->addDirectory(__DIR__)
			->register();

		$configurator->addConfig($appDir . '/config/application.neon');
		//$configurator->addServices(['router' => new SimpleRouter('Web:Default:default')]);

		$router = new RouteList;
		//$router->addRoute('[<path .+>]', 'Web:Default:default');   //Catch-All ???
		$router->addRoute('*', 'Web:Default:default');   //Class->Method
		$configurator->addServices(['router' => $router]);

		return $configurator;
	}

}

My application.neon is:

application:
	catchExceptions: true
	mapping:
		Web : App\Modules\Front\Web\*Presenter


routing:
	debugger: true
	//// Am I missing something here?

and my DefaultPresenter (is in app\modules\front\web\DefaultPresenter

class DefaultPresenter extends Nette\Application\UI\Presenter {

    public function __construct() {
        Debugger::log("A");
    }


    public function renderDefault() : void {
		Debugger::log("B");

	}
}

The error is a 404 – Page not found and Tracy say's “no route”.

What am I missing? How is case-sensitivity?

Can anbody point me to the right direction please? Thank you very much in advance. 😃

Thomas

mskocik
Member | 61
+
0
-

And what's the namespace of your DefaultPresenter? If you are using PSR-4 for autoloading, the namespace should be App\Modules\Front\Web

ttrepper
Member | 11
+
0
-

Thank you for answering @mskocik. I had that namespace but commented that out. If I use it I get the following error:

App\Modules\Front\Web\Nette\Application\UI\Presenter" not found
ttrepper
Member | 11
+
0
-

The error happens at this line:

class DefaultPresenter extends Nette\Application\UI\Presenter {
mystik
Member | 308
+
+1
-

You are missing \ before Nette\Application\… in extends

Without it identifier is relative to current namespace

ttrepper
Member | 11
+
0
-

Very good catch. Thank you very very much @mystik 😃