Categories
Create a New Laravel Project: No-Nonsense, Step-by-Step Guide
- Get Your Environment Ready:
- Fire up your Windows Terminal.
- Get a new session going with your WSL2 Linux system.
- Pick an Application Name:
- You need a name for your Laravel project. We’re going with “myapp.com” for this guide. Laravel isn’t a fan of dots in the name, so we start with “myapp” and switch it to “myapp.com” after.
- Select Your Sail Services:
- Think about the Sail services you’ll use. You’re not stuck with them; you can switch them later if needed.
- This time, we’re opting for MySQL and Redis.
- You’ve got quite a few options:
mysql
,pgsql
,mariadb
,redis
,memcached
,meilisearch
,minio
,selenium
, andmailpit
.
- Kickstart the Project:
- Within your WSL2 session in Windows Terminal, execute:
curl -s https://laravel.build/myapp?with=mysql,redis | bash
- This command is good for MacOS or Linux too. Hit a snag? There’s extra help for MacOS or Linux over at https://laravel.com/docs/10.x/installation#laravel-and-docker.
- While setting up, you’ll see something like this (though the numbers might be different):
latest: Pulling from laravelsail/php82-composer Digest: sha256:12345678901234567890123456789012345678901234567890 Status: Image is up to date for laravelsail/php82-composer:latest _ _ | | | | | | __ _ _ __ __ ___ _____| | | | / _` | '__/ _` \ \ / / _ \ | | |___| (_| | | | (_| |\ V / __/ | |______\__,_|_| \__,_| \_/ \___|_| WARN TTY mode requires /dev/tty to be read/writable. Creating a "laravel/laravel" project at "./myapp" Installing laravel/laravel (v10.2.6)
- Docker will take a few minutes to get your containers ready.
- Heads up: the script will want your sudo password. Using WSL2 on Ubuntu? It’s likely “ubuntu”.
- Within your WSL2 session in Windows Terminal, execute:
- Change the Project Directory Name (If You Want):
- Done with the setup? You can now rename your project folder. We’re going from “myapp” to “myapp.com”.
mv myapp myapp.com
- Done with the setup? You can now rename your project folder. We’re going from “myapp” to “myapp.com”.
- Get Laravel Sail Going:
- Move into your project directory and fire up Laravel Sail:
cd myapp.com/ sail up -d
- Remember, you’ll want to use
sail
for command-line tasks on your app from here on.
- Move into your project directory and fire up Laravel Sail:
- Start Working in VSCode:
- Get Visual Studio Code up with:
code .
- Get Visual Studio Code up with:
- Use Laravel Vite:
- Run Laravel Vite with this command:
sail npm run dev
- Run Laravel Vite with this command:
- Check Out Your App:
- Open your browser and head to
http://localhost/
. Your app is waiting for you right there.
- Open your browser and head to