N.B. In the video introduction, I refer to this video as “Part 2”, which is incorrect—this is actually part 3. In part 1, we went through setting up Composer, which is used to manage dependencies, and also Valet, which is used to set up a hosting environment. In part 2, we covered using valet to generate domains automatically.
In this post, part 3, we'll cover installing Statamic and setting up a site. The best way to do this is to install a couple of starter kits. I recommend you first install a plain ol’ Statamic installation so you can start building things from scratch and then secondly install a starter “kit”, which is a pre-made website which we can copy and learn from.
To start, go to the Installation page in the docs: https://statamic.dev/installation. There are two different ways to install Statamic using Composer. The recommended way is to install the Statamic CLI (Command Line Interface)—this adds a “helper” layer on top of Composer, so it's the preferred way to go. Run the command:
composer global require statamic/cli
After this dependency is installed, try running:
statamic new somesitename
If You Get the Error: command not found: statamic
This is an issue with your $PATH not having the global .composer/vendor/bin
directory in it (source). Try the following:
Run
sudo nano /etc/paths
Use your down arrow key to go to the bottom of the list and add a new line called
/Users/your-username-here/.composer/vendor/bin
Exit nano by pressing
ctrl + x
and sayyes
to saveClose the Terminal window and open a new one
Try the command again:
statamic new somesitename
Use the Wizard to Install A Starter Site and Starter Kit
Once you've got the interactive wizard going, first make sure you're in your Sites
directory in Terminal, then run statamic new starter
. When the wizard asks you “Which Starter kit would you like to install from?” type 0
to select the first option and install a Statamic starter site.
When the script runs don't worry about any “package abandoned” yellow warnings—this is more of a soft concern for the Statamic developer team to address in future Statamic releases.
Rerun the wizard; `statamic new kit`
. When the wizard asks you “Which Starter kit would you like to install from?” choose a kit, e.g. type 3
.
Make Sure You Have Your Domains Set Up
At this point, if you're using valet park
to “park” your Sites
directory, you should be able to go to the relevant domain e.g. http://starter.wip
or the default TLD of http://starter.test
I'd still recommend you secure the site by typing the command valet secure yoursitename
. It takes 2 seconds and a) gets rid of the ugly red padlock, and b) bear in mind your live site will be HTTPS, so it gets us one step closer to your production environment with minimum effort.
Once you've secured your domains you should be able to go to:
https://starter.wip
https://nameofyourkit.wip
Create A User to Gain Access to the Control Panel
You'll first need to create a user to access the control panel. You can do this by:
First, make sure you are in your starter site directory, e.g. run the command
cd /Users/yourhomedirectoryhere/Sites/starter
Run
php please make:user
(documentation)Go through the wizard questions
Now you should be able to go to the control panel e.g. https://starter.wip/cp
. You can now repeat the process for your second site…
First, make sure you are in your starter kit site directory, e.g. run the command
cd /Users/yourhomedirectoryhere/Sites/nameofyourkit
Run
php please make:user
Go through the wizard questions