Unable to access module. 404
- kevin.waterson@gmail.com
- Member | 81
Hi am creating a simple blog module using the documentation for modules at https://doc.nette.org/…n/presenters
I have the file app/BlogModule/presenters/BlogPresenter.php which contains
<?php
namespace BlogModule;
class BlogPresenter extends Nette\Application\UI\Presenter
{
// …
}
However, I am getting a 404
Nette\Application\BadRequestException #404
Cannot load presenter ‘Blog’, class ‘App\Presenters\BlogPresenter’ was
not found
What, or how many things, am I doing wrong?
Does the BlogModule need to be ‘registered’ in config or something?
A custom route?
htaccess issue?
Thanks Kev
- Petr Parolek
- Member | 458
Hi,
you have to use namespace App\BlogModule\Presenters
or change
mapping in config.neon
- kevin.waterson@gmail.com
- Member | 81
Thanks for you replies.
The issue still persists when accessing the /blog/blog or even /blog
?php
namespace App\BlogModule\Presenters;
class BlogPresenter extends Nette\Application\UI\Presenter
{
// …
}
Is there something which needs to be present in config to enable modules?
The presenter is located in app/BlogModule/presenters/BlogPresenter.php
Error:
Nette\Application\BadRequestException #404
Cannot load presenter ‘Blog’, class ‘App\Presenters\BlogPresenter’ was
not found.
- kevin.waterson@gmail.com
- Member | 81
Ahh thanks.
This fixes the error of Blog class not found, however, there is no route.
Nette\Application\BadRequestException #404
No route for HTTP request.
Do I need to create a custom route?
Thanks
Kevin
- kevin.waterson@gmail.com
- Member | 81
This is my config.neon file
parameters:
application:
errorPresenter: Error
mapping:
*: App*Module\Presenters*Presenter
session:
expiration: 14 days
services:
router: App\RouterFactory::createRouter
This is the router:
<?php
namespace App;
use Nette;
use Nette\Application\Routers\Route;
use Nette\Application\Routers\RouteList;
final class RouterFactory
{
use Nette\StaticClass;
/**
* @return Nette\Application\IRouter
*/
public static function createRouter()
{
$router = new RouteList;
$router[] = new Route(‘<presenter>/<action>[/<id>]’,
‘Homepage:default’);
return $router;
}
}
I should add that this is an install simply using composer.
Last edited by kevin.waterson@gmail.com (2019-03-11 10:25)
- kevin.waterson@gmail.com
- Member | 81
Problem still exists.
URL is /blog:blog/default
My config now looks like this:
I am guessing I am doing something fundamentally wrong or immoral.
Kevin
Last edited by kevin.waterson@gmail.com (2019-03-11 23:41)
- kevin.waterson@gmail.com
- Member | 81
OK, noted.. now we have come full circle ..
/blog.blog/default
The path to my presenter is: app/BlogModule/presenters/BlogPresenter.php
My presenter looks like this:
- kevin.waterson@gmail.com
- Member | 81
When I change ‘presenters’ to Presenters, the only thing which changes is the error message.
However, when the App is changed to app, we get past the error
And this presents a new error…
to fix this, we need to have access to Nette namespace, so in the BlogPresenter class..
Then, when I change the filesystem to have app/BlogModule/templates/Blog/default.latte it works. (this will be a new thread)
Thanks for help resolving this for a newbie.
Kev