Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cristian9509's avatar

How to display regular *.php files from inside the public folder

I have a project in which everything is built in Laravel. I also have a small module that was build using regular php routes. I need to do a short demonstration of what I currently have but also of the old module. I am in a time crunch and won't have enough time to import everything into laravel although the next thing in my check list is to import that module in the project.

So, I need to temporarily make it work somehow. Is it possible?

0 likes
9 replies
pmall's avatar
pmall
Best Answer
Level 56

Just put your file in public and it should work wen you access it

1 like
cristian9509's avatar

@pmall Well that actually works. I was just doing a stupid mistake and not putting the files inside the public folder!

1 like
markvdputten's avatar

Anyone knows if this is still possible? I have created public/test.php but when I open it up I am getting a 404 not found error...

When creating test.html... that does display...

Cronix's avatar

@markvdputten what's your server setup and environment? Most likely it's a htaccess/nginx setting. I'm using homestead and putting a test.php file in /public that just contains phpinfo(); displays fine when going to http://mysite.dev/test.php

1 like
drehimself's avatar

@markvdputten

I am using valet as well and am getting the same error.

Using php artisan serve works

It must be some sort of nginx configuration that valet does.

2 likes
markvdputten's avatar

@drehimself

Damn! Yes you are right!

Ill look into the nginx configuration to see if I can find what is causing this... if I do, I will write it down here so you can if it as well :)

Thanks!

tgugnani's avatar

@markvdputten Were you able to solve this. I am facing a similar issue on my server, where php files inside public folder gives me 404. Works fine on local.

markvdputten's avatar

@tgugnani for me it was the other way around if I remember right, it did not work locally but worked on the server... but it is a while back to be fair...

Please or to participate in this conversation.