How to install Craft 5 beta locally so you can become familiar with the changes.
You can get Craft 5 up and running locally in three ways.
No matter which way you run Craft 5 locally, Craft 5 requires PHP 8.2, so keep that in mind, especially if you’re running a local setup that uses local PHP instead of something easily configurable in a Docker container.
We’ll use DDEV but you do you.
Let’s walk through each one briefly and learn which one is best for you!
To set up a fresh copy of Craft 5, we’ll use DDEV as our localhosting tool.
First, let’s create the directory where we want the project to live. I use a ~/training
directory in my user home directory.
cd ~/training
mkdir craft5
cd craft5
Now that we’re in the project, we need to configure it for DDEV, using the ddev configure
command. We’ll pass in some options with the command so we don’t need to go through the wizard steps.
ddev config --project-type=craftcms --docroot=web --create-docroot --php-version=8.2
Okay, now we can grab the Craft starter project via Composer using the ddev composer create
command (which is slightly different than the composer create-project
command but does the same thing).
ddev composer create -y --no-scripts craftcms/craft=5.0.x-dev
We’re passing in some options to skip the wizard and to use the 5.0.x‑dev version of the application from Packagist.
Finally, we’re ready to install Craft in our local environment:
ddev craft install
After completing everything, let’s navigate to the browser and check out Craft 5!
One caveat to using this setup: this should be a vanilla Craft project and not a project that is set up with multiple third-party plugins or a custom module. You will likely fail with the update since the plugins you use still need to support Craft 5.
Our purpose here is to only learn about Craft, not upgrade an actual project.
First things first, we need to make sure our existing DDEV environments (or whatever envrionment you’re running locally) supports PHP 8.2. For DDEV it’s as simple as updating the config.yaml
file or running the following command:
ddev config --php-version=8.2
Then we need to restart DDEV to rebuild with the new version of PHP:
ddev restart
We also need to update the composer.php
file to require PHP 8.2 — this is important to ensure we have Composer package compatibility with the PHP version we’re running.
Staying in the composer.php
file, we need to change the version of craftcms/craft
to the 5.0 dev version:
craftcms/cms: '5.0.0-beta.1'
If you have the first-party plugin Craft Generator installed, then you’ll also need to update it.
craftcms/generator: '2.0.x-dev'
Now we’re ready to update Craft!
First, Composer, so we get the updated version of our dependencies:
ddev composer update
And then we’ll do any project config and migrations via craft up
:
ddev craft up
And, we’re done!
Another option to start working with Craft 5, and the one that requires the least amount of work is to use Andrew Welch’s Spin Up Craft 5 repository.
Andrew created a Github repository that makes it simple to spin up a vanilla Craft 5 project in the cloud, using Github Codespaces, without any setup of your own.
Github Codespaces allows developers to create and manage fully-configured development environments directly within the GitHub ecosystem. Developers can work on their projects in a web-based editor or even connect to their favorite desktop IDE. It eliminates the need for local development setups and provides a consistent and reproducible environment for collaborative coding.
Pretty cool.
Make sure you’re logged in to your Github account and then go to Andrew’s Craft 5 Spin Up repository.
Scroll down to the README and click the “Open in Github Codespaces” button.