Invalid link: Cannot load presenter ‘Post’, class ‘App\Presenters\PostPresenter’ was not found

Notice: This thread is very old.
muhammadnaveed
Member | 11
+
0
-

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);
    }
}
Jan Endel
Member | 1016
+
+1
-

Can you paste here whole PostPreseter.php file?

David Matějka
Moderator | 6354
+
0
-

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
+
0
-

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 | 6354
+
0
-

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
+
0
-

PostPresenter.php is located in the Presenters folder but still not working :(

Jan Endel
Member | 1016
+
0
-

when you have this error message, you can always try most error fixing approach:
- run command composer dump-autoload in folder when you have your project
- clear your /where/is/your/project/temp folder

muhammadnaveed
Member | 11
+
0
-

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
+
0
-

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 :) :) :)