In one sentence

With PHP, Composer and Node installed, one laravel new command gives you a complete, working app you can open in your browser.

🏠It's like moving into a furnished flat instead of an empty plot. The walls, plumbing and wiring (routing, database, security) are already in; you just bring your own furniture (your features).

Why it matters

A good setup saves hours later

⚑

Running in minutes

Laravel ships with sensible defaults, including a ready-to-use SQLite database. There's no server to configure before you see a page.

🧰

Tools you'll use daily

Composer, Artisan and npm are the commands you'll type every day. Getting them working now pays off in every later lesson.

πŸ”

Settings kept safe

The .env file keeps passwords and keys out of your code, and out of Git.

The big picture

From nothing to β€œit works!”

🧱PrerequisitesPHP 8.2+, Composer, Node
πŸ“¦Installerlaravel/installer
✨laravel new blogcreates the project
▢️composer run devstarts everything
🌐Browserhttp://127.0.0.1:8000
Five stops, most of them one-time. After the first project, a new app is just laravel new.
🐘

PHP 8.2+

The language Laravel is written in. Check with php -v.

🎼

Composer

PHP's package manager. It downloads Laravel and its libraries. Check with composer -V.

🟒

Node.js & npm

Builds your CSS and JavaScript with Vite. Check with node -v.

Step by step

Create your first Laravel app

We'll build a project called blog, which you'll keep growing throughout the course.

  1. Install the tools (the easy way: Herd)

    Laravel Herd is a free desktop app for Windows and macOS. One installer gives you PHP, Composer, the Laravel installer and a local web server. It's the fastest way to start.

    Download it from herd.laravel.com, run it, and open a new terminal. Then check everything is there:

    
              php -v
              composer -V
              laravel --version
            

    Install Node.js (the LTS version) separately from nodejs.org if you don't already have it.

    ℹ️ Prefer to install by hand?

    That's fine too. Install PHP 8.2+ (with common extensions), then Composer from getcomposer.org, then add the Laravel installer globally:

    
                composer global require laravel/installer
              

    Make sure Composer's global vendor/bin folder is on your PATH so the laravel command is found.

  2. Create the project

    Move to the folder where you keep your code and run laravel new. The installer asks a few questions.

    
              laravel new blog
            
    • Starter kit: choose None for now. Starter kits (React, Vue, Livewire, or the classic Breeze) add login pages; you'll meet them in Starter Kits.
    • Testing framework: Pest or PHPUnit. Either is fine.
    • Database: keep the default, SQLite.
    • Run npm install? Yes.

    No installer? composer create-project laravel/laravel blog does the same job with no questions asked.

  3. Run the app

    Step into the folder and start the development server. php artisan serve starts PHP's built-in web server on port 8000.

    
              cd blog
              php artisan serve
            
    
              INFO  Server running on [http://127.0.0.1:8000].
              Press Ctrl+C to stop the server
            

    Even better, run composer run dev. It starts the web server, the Vite asset builder, the queue worker and a live log viewer, all in one terminal.

    
              composer run dev
            
    πŸ’‘ Using Herd?

    Herd automatically serves any project in its β€œparked” folder at http://blog.test. You only need npm run dev for your CSS/JS.

  4. Meet the .env file

    The .env file holds settings that change between computers, such as your local machine vs. the live server. Laravel reads it on every request.

    
              APP_NAME=Blog
              APP_ENV=local
              APP_KEY=base64:Xv3...generated...
              APP_DEBUG=true
              APP_URL=http://localhost
    
              DB_CONNECTION=sqlite
            
    • APP_KEY encrypts cookies and sessions. It's generated for you; never share it.
    • APP_DEBUG=true shows detailed error pages. It must be false in production.
    • In your code, read settings with config('app.name'), which pulls from the files in config/, which in turn read .env.
    ⚠️ Never commit .env

    It's already in .gitignore. Commit .env.example instead, a template without real secrets. A teammate copies it to .env and runs php artisan key:generate.

  5. Check the database (SQLite by default)

    SQLite stores the whole database in one file, database/database.sqlite. There's no server to install. The installer has already created it and run the first migrations (the scripts that build tables).

    
              php artisan migrate:status
            

    Want MySQL or PostgreSQL later? Change the DB_* lines in .env and run php artisan migrate. You'll learn more in Migrations.

    
              DB_CONNECTION=mysql
              DB_HOST=127.0.0.1
              DB_PORT=3306
              DB_DATABASE=blog
              DB_USERNAME=root
              DB_PASSWORD=
            
Common mistakes

Avoid this, do that

❌ Avoid

          $key = 'sk_live_123abc';   // in a controller
        

Secrets hard-coded in PHP files end up in Git history forever.

βœ… Do

          // .env:  STRIPE_SECRET=sk_live_123abc
          // config/services.php:  'secret' => env('STRIPE_SECRET'),
          $key = config('services.stripe.secret');
        

Put secrets in .env, read them with env() in config files only, and use config() everywhere else.

❌ Avoid

          Edited .env... page still shows old value πŸ€”
        

If you ran php artisan config:cache, Laravel stops reading .env until the cache is cleared.

βœ… Do

          php artisan config:clear
        

Locally, don't cache config at all. Clear it whenever .env changes seem to be ignored.

πŸ’‘ Pro tip: meet Artisan

Artisan is Laravel's command-line helper. List every command it knows, or get help on one:


        php artisan list
        php artisan help make:controller
        php artisan about
      
πŸ‹οΈ Try it yourself
  1. Create a new project called blog and open it at http://127.0.0.1:8000 (or http://blog.test with Herd).
  2. Change APP_NAME in .env to β€œMy Blog” and print it with {{ config('app.name') }} in resources/views/welcome.blade.php.
  3. Run php artisan about and find your PHP version, Laravel version and database driver.
  4. Stop the server, then start it again with composer run dev and see the extra processes it runs.
Recap

Key takeaways

Check yourself

Mini quiz