Invalid link: Cannot load presenter ‘Post’, class ‘App\Presenters\PostPresenter’ was not found
- muhammadnaveed
- Member | 11
I am new to Nette Framework I really like it but I am facing a problem
even everything is ok according to the tutorials but it shows me the following
warning, Please answer in English, I saw some solutions while searching but
that was all in other language so it was not useful for me. I asked the same
question on stackoverflow but there are very limited question about Nette there
and I think Nette is not widely used outside Check Republic even it a very nice
framework.
Invalid link: Cannot load presenter ‘Post’, class
‘App\Presenters\PostPresenter’ was not found.
<?php
namespace App\Presenters;
use Nette,
Nette\Application\UI\Form;
/**
* Post presenter.
*/
class PostPresenter extends BasePresenter
{
/** @var Nette\Database\Context */
private $database;
public function __construct(Nette\Database\Context $database)
{
$this->database = $database;
}
public function renderShow($postId)
{
$this->template->post = $this->database->table('posts')
->get($postId);
}
}
- David Matějka
- Moderator | 6445
Hi, I assume, that you follow the quickstart and you are now in this
section, am I right? I probably see the problem. Since 2.3, Nette shows
warning when a link is not valid. And a quickstart is a bit outdated – the
link to the Post presenter is created before we add the PostPresenter. So just
remove that {link ...}
(or n:href
) macro until you
reach the next
chapter, where PostPresenter is created.
- muhammadnaveed
- Member | 11
Thanks for your Answer. I have created the PostPresenter.php and a folder Post which contains a template called show.latte but it still giving me the same problem, I tried changing the names from post to something else but it is still not working! :(
- David Matějka
- Moderator | 6445
To which folder did you put PostPresenter.php
file? It must be
somewhere inside the app
folder, so Robot loader can locate it.
Best in the app/presenters
folder right next to the other
presenters.
- muhammadnaveed
- Member | 11
PostPresenter.php is located in the Presenters folder but still not working :(
- muhammadnaveed
- Member | 11
OMG! Jan Endel Thank you so much, it fixed the problem, I was have this problem from about 2 days but I was failed to solve, “composer dump-autoload” worked like ghost :) :) :)
- muhammadnaveed
- Member | 11
OMG! Jan Endel Thank you so much, it fixed the problem, I was have this problem from about 2 days but I was failed to solve, “composer dump-autoload” worked like ghost :) :) :)