Currently Available: Need a skilled Software Developer for your next project?
Categories
Laravel

Create a New Laravel Project: No-Nonsense, Step-by-Step Guide

Get Your Environment Ready

  1. Open your Windows Terminal.
  2. Start a new session with your WSL2 Linux system.

Choose an Application Name

  • Select a name for your Laravel project. For this guide, we'll use "myapp.com". Note that Laravel doesn't support dots in the project name, so we'll start with "myapp" and change it to "myapp.com" later.

Decide on Your Sail Services

  • Consider the Sail services you'll need for your project. You can change these later if necessary.
  • For this example, we'll use MySQL and Redis.
  • Available options include: mysql, pgsql, mariadb, redis, memcached, meilisearch, minio, selenium, and mailpit.

Initialize the Project

  • In your WSL2 session within Windows Terminal, run the following command:
curl -s https://laravel.build/myapp?with=mysql,redis | bash
  • This command also works for MacOS or Linux. If you encounter issues, refer to the additional help for MacOS or Linux.
  • During the setup process, you'll see output similar to the following (numbers may vary):
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 require a few minutes to prepare your containers.
  • Note: The script will prompt for your sudo password. If you're using WSL2 on Ubuntu, the password is likely "ubuntu".

Rename the Project Directory (Optional)

  • After the setup is complete, you can rename your project folder. In this example, we'll change it from "myapp" to "myapp.com".
mv myapp myapp.com

Start Laravel Sail

  • Navigate to your project directory and start Laravel Sail:
cd myapp.com/
sail up -d
  • From now on, use the sail command for command-line tasks related to your application.

Open the Project in VSCode

  • Launch Visual Studio Code with the following command:
code .

Run Laravel Vite

  • Execute the following command to run Laravel Vite:
sail npm run dev

Access Your Application

  • Open your web browser and navigate to http://localhost/. Your application should be accessible at this URL.
What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Subscribe to my newsletter

Get new posts when I publish them.

I respect your privacy. Unsubscribe at any time.

Leave a Reply

Your email address will not be published. Required fields are marked *