Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Install Craft CMS v4 with one command via DDEV
Matthias Andrasch
Matthias Andrasch

Posted on • Edited on

     

Install Craft CMS v4 with one command via DDEV

2023 was another great year for Craft CMS:2023 in Review. There are now over 8'000 developers registered inCraft Discord according to the latestState of Craft talk by Brandon Kelly.

Do you want to try it quickly?

Looking forCraft v5?

Requirements

If you haven't installed a Docker runtime, you might be happy withOrbstack. Other alternatives:DDEV docs: Docker installation.

Afterwards you can simply install DDEV via homebrew (on Mac):

brew install ddev/ddev/ddev && mkcert -install
Enter fullscreen modeExit fullscreen mode

Check if it was successful withddev -v.

For other operating systems seeDDEV docs for setup instructions.

Install CraftCMS v4

Get the latest CraftCMS v4 version with this one command:

mkdir craft4-ddev && \   cd craft4-ddev && \  ddev config \    --project-type=craftcms \    --docroot=web \    --create-docroot \    --php-version="8.2" \    --database="mysql:8.0" \    --nodejs-version="20" && \  ddev start -y && \  ddev composer create -y --no-scripts --no-interaction "craftcms/craft:^4" && \  ddev craft install/craft \    --username=admin \    --password=password123 \    --email=admin@example.com \    --site-name=Testsite \    --language=en \    --site-url='$DDEV_PRIMARY_URL' && \  echo 'Nice, ready to launch!' && \  ddev launch
Enter fullscreen modeExit fullscreen mode

You will be greeted with the default index template:

Image description

You can also open the backend via

ddev launch /admin
Enter fullscreen modeExit fullscreen mode

and login viaadmin andpassword123.

Craft login

Automate it

You can take this one step further and generate the folder (and therefore project names) dynamically. Thanks very much toAugust Miller for this recommendation!

TIMESTAMP_FOLDER=$(date +'%Y%m%d-%H%M');mkdir"craft4-$TIMESTAMP_FOLDER"&&cd"craft4-$TIMESTAMP_FOLDER"&&\ddev config\--project-type=craftcms\--docroot=web\--create-docroot\--php-version="8.2"\--database="mysql:8.0"\--nodejs-version="20"&&\ddev start-y&&\ddev composer create-y--no-scripts--no-interaction"craftcms/craft:^4"&&\ddev craftinstall/craft\--username=admin\--password=password123\--email=admin@example.com\--site-name=Testsite\--language=en\--site-url='$DDEV_PRIMARY_URL'&&\echo'Nice, ready to launch!'&&\ddev launch
Enter fullscreen modeExit fullscreen mode

But beware to not fill up your local harddrive too much. Delete DDEV projects withddev delete (orddev delete -O without snapshot) and keep your projects organized withddev list. You can also useddev delete -O <project-name>.

Try it out online with GitHub Codespaces

If you don't want to install Craft CMS v4 locally, you could also launch a new Github Codespace instance here:

Screenshot launch codespace

Paste the command from above into the terminal:

Screenshot codespaces terminal

Open port 8080 (web) in the simple browser or in a new browser tab in the ports section:

Screenshot codespaces with Craft CMS open

Have fun trying out Craft CMS!

More Resources:

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Keep it simple. Sustainable Web Design & Open Source for the win. https://sustainablewebdesign.org/
  • Location
    Vienna, Austria
  • Joined

More fromMatthias Andrasch

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp