Confusion about two .htaccess files

Kami
Member | 2
+
0
-

Hi (newbie here),

I am going through the “Create Your first Application!” tutorial to familiarize myself with this great framework but am running
into a few basic issues.

Before the first Presenter is created, everything works fine (i.e: Welcome Page, Cleanup, Tracy, “quickstart” Database and “posts” table creations.)

I see the welcome page fine here : http://localhost/nette-blog/www/

Once I created the renderDefault() method in the HomepagePresenter Presenter class and tried to retrieve all posts in the default.latte template, I only see the code and no data is retrieved from the database table.

I guess I do not understand through those first two tutorial pages ( https://doc.nette.org/en/quickstart and http://localhost/nette-blog/www/) how Nette routing system works and how a template or view is called from the controller.

I actually get a parsing error in the declaration of the private property $database on line 10 in the HomepagePresenter class
(line 10: private Nette\Database\Explorer $database;), no matter if I use the code shown in the tutorial or in Nette tutorial on its github page.

My second question has to do with two .htaccess files automatically created during the installation.

  1. nette-blog\.htaccess
  2. nette-blog\www\.htaccess

How are they supposed to be properly configured ?

Thank you for your time.

KBW

David Grudl
Nette Core | 8218
+
0
-
  1. tutorial is written for PHP 7.4 or newer and I think you are using lower version
  2. What do you mean by properly configured?
Kami
Member | 2
+
0
-
  1. I am using PHP version 7.3.7, I don't think that there is anything in the HomepagePresenter class (in the beginners tutorial) which should cause any conflict.
  2. I had to search the internet to find a way to configure the .htaccess file in nette-blog\www\.htaccess so that the welcome page is properly displayed. The unmodified .htaccess file created by composer leads the application to show an error 403 page.

I am asking the question for both .htaccess files because the tutorial mentions that only files in the www folder should be
accessible by the public.

(by “configure”, I just mean what is its content.)

Last edited by Kami (2021-04-07 18:10)

David Grudl
Nette Core | 8218
+
0
-

private Nette\Database\Explorer $database causes the conflict, in PHP 7.3 it should be only private $database.

Welcome page is actually displayed only in nette-blog/www/, not in nette-blog/. It is basically the intention to make it impossible to open in browser other folders, such as nette-blog/app/ or nette-blog/log/.