It's best to run all `craft` commands through the `nitro` command.
Let’s look back at the project we created in the beginning of the course.
➜ cd ~/training/learnnitro
If I wanted to check if there are any updates to plugins or Craft for this project, I would typically run
➜ craft update/info
I like to do this to get an idea what’s available and then plan my next steps.
But if I run that command, I get a SQL error. Craft checks the database when running Craft commands and based on what I have set in the .env file for this project, the Craft console command cannot connect to the database. This because internal to the Docker network, the MySQL database server port is 3306. However, externally, it is 3307. I don’t want to change my .env file, so I’ll use the nitro command instead as a way to run commands as if I was inside the Docker network.
It’s quite simple, really. I just prepend everything with the nitro command and then run the craft command as a subcommand.
➜ nitro craft update/info
And that works!
Because of this, I recommend running all craft commands through the nitro command, just to be sure you don’t run into any issues.