0

This is driving me nuts because it seems like such a critical thing that I would expect there to be a lot of people asking, but I can't find a clear cur response to.

I want to follow along a simple php tutorial like this one: https://www.youtube.com/watch?v=dbZYRNgGAKE

I installed everything I need. Now what? How do I run a php file?

  • 4
    I really doubt if people are gonna watch a video to help. Can you post a specific error? – EODCraft Staff Apr 04 '18 at 09:36
  • 4
    You can run it by php /path/to/your/file.php or with your browser if you have and configured apache on it. – Ali Razmdideh Apr 04 '18 at 09:41
  • Please check this : http://php.net/manual/pl/features.commandline.webserver.php – Michal Przybylowicz Apr 04 '18 at 09:46
  • How do I run the file? Let's say I have a .php file. I can't figure out the command to run it – quantumbutterfly Apr 04 '18 at 09:49
  • Your question isn't clear. You would get much better help if you would copy and paste text from your computer screen with what you have attempted, any output or error messages you are getting, as well as other details of what you expect. I clicked on your link, but don't have seven minutes to run the video to try to figure out where you're going wrong. – L. D. James Apr 04 '18 at 10:57
  • 3
    @Melebius You don't need a LAMP stack to run php locally. You can run the php interpreter locally in interactive mode with php -a although that's an oversimplification, but I voted to leave this question open anyway. – karel Apr 04 '18 at 11:23
  • 2
    @MichalPrzybylowicz Thanks! The link you provided explains a much better way than setting up an entire LAMP stack or XAMPP like most sources suggest to do. If you submit that as an answer, I'll accept it – quantumbutterfly Apr 04 '18 at 11:41
  • It always bothers me to see a question with a pending accept voted answer reviewed as "unclear what you are asking" as this question has been reviewed by some of its reviewers. – karel Apr 04 '18 at 11:49

1 Answers1

3

Okay, so here's the simple answer I would have loved to find but couldn't

  1. cd into the directory the file is in

  2. Run php -S localhost:8000 (or replace 8000 with a different port)

  3. Go to localhost:8000 in the browser

Melebius
  • 11,431
  • 9
  • 52
  • 78