Getting started - building site locally

I’ve just downloaded the Kirby plain kit to my Mac.

I’d like to build a website on my Mac before putting it on a server. I understand this is called ‘local’ or building ‘locally’?

When I open the index.php file in my browser I get the following message:

<?php

require 'kirby/bootstrap.php';

echo (new Kirby)->render();

I presume that I can not view PHP files in my browser locally, without doing something first?

So following the Kirby video I’ve dragged the plainkit-main folder into Terminal and typed in “php -S localhost:8000 kirby/router.php”, but I just get the following text:

zsh: command not found: php

What does that mean?

After dragging the plain kit-main folder into Terminal should I press the return key before typing php -S localhost:8000 kirby/router.php ?

So how can I see my website locally?

It looks like you don’t have PHP installed.
I don’t use Mac, but as far as I understand it, the easiest way to install PHP on a Mac is via “homebrew”.

So you might want to start by installing that from here: https://brew.sh/
Once installed, you should be able to install PHP by typing “brew install php” (then enter) in a terminal.

After that, you can try again with php -S localhost:8000 kirby/router.php

The point is that you should run the command while your working directory in the terminal is the folder where the starterkit is. So, you write the command cd (change directory) and then the path to the folder (dragging the folder into the terminal just writes the path for you). After that, you probably have to confirm the whole command with Enter. If you’re not sure, pressing enter doesn’t hurt (an empty command line does nothing). If you drag the folder into terminal and hit return, you land inside the directory (thanks @texnixe).

If you don’t get an error, you should then see your website by entering http://localhost:8000 into a browser address bar.

If you drag the folder into terminal and hit return, you land inside the directory.

Since (insert recent macOs, because I’m not sure since when) Macs don’t come with PHP pre-installed anymore, so yes, you have to install it first.

Alternatively, you could for example install MAMP which does all the installation stuff for you.

https://www.mamp.info/

Thank you. Installing PHP on my Mac sounds beyond me, so I’ll try MAMP