Couldn't get Step 06 to work
zethon opened this issue · 10 comments
Struggled with Part 6 for a while because it kept telling the class Example\Controllers\Homepage
could not be found. Took me about two hours to figure out I needed to run composer update
.
This is not immediately obvious and should be mentioned in the tutorial.
Thanks! I was struggling with the same issue, luckily I saw your issue. After a while, I realized my problem was the working directory where I was running the server.
You should use public directory to run php -S localhost:8000
instead of root directory.
Need a .htaccess file in your public folder.
Sorry I don'T get it. When I put the index.php in the root and echo a simple "hello world" all is fine.
Why do I need the htaccess now? And what should I put into htaccess?
@Wondarar you need to start your server in the public so either:
php -S localhost:8000 -t public/
from the root of your project or directly from public folder:
cd public
php -S localhost:8000
I see you created virtual host testsite2.loc so make sure it points to public folder, not the root of your project.
.htaccess is not required :)
Ok, since not required I skip that.
Here's the testsite2.loc.conf file and in yellow what I added today (which is obsolete then anyways).
Where do I set the pointer to public? Is it within this conf file? Is it in line 12, adding \public ?
If I understand it correcty, $routeInfo should NOT give me an empty array?
But since it keeps being empty it correctly resolves to the 404.
And here's the Route.php
Your config is invalid. <Directory>
block should be inside <VirtualHost>
. Here's an example:
<VirtualHost *:80>
# first VH is default for apache - do not change it
</VirtualHost>
<VirtualHost *:80>
ServerName mysite.test
DocumentRoot "/path/to/mysite/public"
<Directory "/path/to/mysite/public">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
Then make sure /etc/hosts
file has valid IP pointer for mysite.test. Here's well written tutorial
Leave this first <VirtualHost>
untouched. It's default for the apache. Just add another below.
Glad I could help :)
Issue resolved so you can close it now.