Create a free account to get access to additional free training videos. Enjoy this free video from CraftQuest! Create a free account to get access to additional free training videos. Join the Community
Now that we have Nitro installed, we are ready to create our first Craft hosted with Nitro.
Now that we have Nitro installed, we are ready to create our first Craft hosted with Nitro. For this video, we’ll focus on setting up a new site with Nitro. In the next video we’ll look at migrating an existing project.
Nitro is a global command, so we do not install anything inside of our project. That means we can pick where we want to store our project files on our local computer and then initialize a new project there using Nitro.
The command we will use for this example is
I do this in the
training directory in my user directory on my computer. This is where I keep all of the projects I use to create these training videos and write articles. For my actual work where I create projects for myself or for clients, I use the
projects directory in my user directory.
nitro create command that we will use does two things: it creates a new Craft project (like you would with
composer create-project) and it adds that project to Nitro (like you would do in an existing project with
nitro add — more on that later).
So, find a place on your file system where you want to install a fresh copy of Nitro, and let’s get started.
➜ cd ~/training
With the project directory created, we can now run
nitro create. This command takes one argument, which is the name of the project. Nitro will create the directory for the project based on the name and name the hostname based on the name, too.
➜ nitro create learnnitro
This downloads the Craft application begins the setup process. This an interactive setup process, so we will be asked to confirm or input some settings.
The first one is the hostname. It will default to the name of the directory and then the .nitro local TLD. Hit Enter to accept as it is. Anything in the square brackets is the default input if we just hit Enter and do not specify anything custom.
The website’s webroot will default to
web, which we want to keep since that is the default directory name in a new Craft installation.
The next step is to choose the PHP version. My advice here is to choose the PHP version that is the same as running in production. Let’s choose 7.4.
We do need a database for this project because Craft requires one, so we will choose Y, and we will choose the database engine for MySQL.
In Nitro, I typically name the database after the hostname and project name it’s easy to find the database I need. So we will input
learnnitro as the name of the database.
Now Nitro will update the project
.env file so it has the credentials needs to connect to the database.
At this point, Composer will kick in and download the dependencies for the Craft project. This process is similar to the part where we run
composer create-project craftcms/cms when setting up a new project without Nitro.
Now Nitro spins up the Docker containers and makes sure everything is working as expected.
We will be Wprompted for your admin password so Nitro can update the hosts file on your computer. On macOS, this is located in
That is it! The containers are running!
Our next step is to run
craft setup and get the site configured. For this step, we want to interact with Craft through the container. For that reason, we will prepend
nitro to our
➜ nitro craft setup
Choose the project we create by inputting the number and then follow the prompts to set up Craft.
It will now run the installation process and populate the database with the default data needed to start a new Craft project!
Let’s fire up the browser and see what is there. Go to https://learnnitro.nitro to see the site!
Here are all of the videos in Local Development with Craft Nitro:
|1||What is Craft Nitro?||Craft Nitro is a Docker-based local hosting solution by Pixel & Tonic, the developers of Craft. It is designed as an officially-supported way to handle local development of Craft CMS website builds, as well as when working on plugin development.||04:08|
|2||Is Craft Nitro Right for Me?||Five checks to see if Craft Nitro is the local development environment for you.||02:33|
|3||How to Install Craft Nitro||Installing Craft Nitro on macOS requires Docker, so that means you need to first have Docker Desktop for Mac installed and working.||09:20|
|4||Creating Your First Site with Nitro||Now that we have Nitro installed, we are ready to create our first Craft hosted with Nitro.||09:49|
|5||Setting Up A Boilerplate Project with Craft Nitro||If you have a boilerplate project that you work with when starting new projects, it’s simple to use that to create a new Nitro project via the `nitro create` command.||04:35|
|6||Migrating an Existing Project to Craft Nitro||Migrating an existing project to Nitro is probably going to be the most common scenario you run into, assuming you move all of your projects over instead of just using Nitro for new projects.||05:04|
|7||Running Craft Commands Against a Craft Nitro Site||It's best to run all `craft` commands through the `nitro` command.||02:15|
|8||Craft CMS Multi-Site with Craft Nitro||Supporting a Craft multi-site installation with Craft Nitro requires using the `nitro alias` command.||04:33|
|9||How to Recall Which Nitro Sites Are Running||I like to be able to get a quick peak and reminds myself of what’s what and if I’ve even set up a project in Nitro yet.||02:58|
|10||Removing a Site from Craft Nitro||Here is how to remove a site from Craft Nitro.||03:05|
|11||Testing Email Sending in Craft Nitro||In addition to the core functionality of local hosting, Craft Nitro also has ancillary services that fill out the total experience of running a Craft site.||05:28|
|12||Updating Craft Nitro||Nitro is an actively maintained project by Pixel & Tonic. You’ll get the best experience with Nitro if you regularly update to get the latest features and improvements.||01:37|
|13||Uninstalling Craft Nitro||If you decide that Nitro isn’t for you or you need to troubleshoot an issue by uninstalling Nitro, then this is how to do it.||02:47|
|Course In-Progress||This course is still being updated with new content. Check back for more!|
Learn how to use Craft Nitro 2 for local development Craft CMS and PHP projects.
Andrew is updating an older Craft 3 sites to use modern web development tools.
Brad Bell and Jason McCallister from Pixel & Tonic join Ryan to talk about the new version of their Docker-based local development environment Nitro.
We answer your questions and walk through Andrew's plugin development setup.
Ryan walks through how to get an existing Craft project running locally on Nitro 2.
Nitro 2 comes with Mailhog support, which makes it easy to test transactional emails sent by Craft.
We cover Nitro 2, Craft 3.6, the Craft executable, and your questions! The Whole Shebang!
A short, first look at the new version of Craft Nitro from Pixel & Tonic.
Invest in yourself, your career, and your ability to take knowledge and use it grow your business or earning potential.
Get everything in the catalog plus new videos every week. Just by signing up you get immediate access to hundreds of hours of learning.