*🚧 Update february 2023: Some installation commands in this tutorial seem to be broken. See DDEV discord for an updated version. Thx to tyler36! 🚧 *
In this little series I try to setup a nice and clean deployment workflow for the PHP CMS Statamic. Statamic is based on Laravel and has strong support for git-centric workflows. Every config change is stored in .yaml
-files and can be version-tracked in git, no database by default (Although a database can be added later).
🚧 This article is work in progress. 🚧
Beware: My goal is to separate content from config as much as possible, therefore I won't rely on Statamics Git Automation. I'll keep the content/
-directory out of git. Let's see how far I can push this as a Statamic newbie.
1. Create a repository
We start by creating a (private) GitHub repository. Add a dummy file like README.md
to begin.
2. Setup Statamic with DDEV and Composer
For the following steps I assume you already installed DDEV on your computer. (Make sure to join the DDEV Discord to meet the wonderful community, there is also a Laravel channel!).
Clone the Github project to your local hard drive, open the project folder in Visual Studio Code. Use the built-in terminal for the following commands below.
So here we go, let's set it up:
# Create configuration for DDEV project ddev config --project-type=laravel --docroot=public --create-docroot # Install latest statamic via composer ddev composer create statamic/statamic # Generate config, set APP_URL & generate key ddev exec "cp .env.example .env" ddev exec 'sed -i "/APP_URL=/c APP_URL=$DDEV_PRIMARY_URL" .env' ddev artisan key:generate # Add support for CLI please command via DDEV-addon: # (https://github.com/mandrasch/ddev-statamic-please) ddev get mandrasch/ddev-statamic-please # Compile JS/SCSS # TODO: Add browsersync as well https://github.com/tyler36/ddev-browsersync#laravel-mix-example ddev exec npm install ddev exec npm run dev ddev launch
This will open your site:
Afterwards you can create your admin user with ddev please make user
:
We can open the control panel via ddev launch /cp
:
Great, that's a functional local setup! 🥳
Commit and push this back to GitHub. If you don't want to store your users in git, add /users
to .gitignore
beforehand.
One last cool thing: DDEV enables to usage of Gitpod as well, check the "Open in Gitpod"-button on mandrasch/ddev-statamic-blank for example to try it out.
Top comments (0)