Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't get Step 06 to work #70

Open
zethon opened this issue Oct 22, 2019 · 10 comments
Open

Couldn't get Step 06 to work #70

zethon opened this issue Oct 22, 2019 · 10 comments

Comments

@zethon
Copy link

zethon commented Oct 22, 2019

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.

@ivanfranco502
Copy link

ivanfranco502 commented Jul 2, 2020

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.

@Wondarar
Copy link

At step6, when running running the site on root, e.g my example is on testsite2.loc, I get:
Imgur
Am I supposed to see it at this step still?
I bet not, I don't know to which step go back and debug.

@Wondarar
Copy link

an on /public I still get the 404....?

Imgur

@ellisgl
Copy link

ellisgl commented Nov 14, 2021

Need a .htaccess file in your public folder.

@Wondarar
Copy link

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?

@SharakPL
Copy link

SharakPL commented Nov 14, 2021

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

@Wondarar
Copy link

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

Imgur

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.

Imgur

And here's the Route.php

Imgur

@SharakPL
Copy link

SharakPL commented Nov 14, 2021

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.

@Wondarar
Copy link

Working now 🥇
Thank you! :)

Imgur

@SharakPL
Copy link

Glad I could help :)
Issue resolved so you can close it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants