Install & Configure Laravel 13 from Scratch – Full Beginner Tutorial
Laravel 13, released on March 17, 2026, is a stability-focused upgrade from Laravel 12 with zero breaking changes, a first-party AI SDK, PHP Attributes for cleaner model and component configuration, and exciting additions like passkey authentication, JSON:API resources, and native vector search support. In this guide, you'll learn exactly how to install Laravel 13 from scratch, configure your environment, and launch your first application.
Table Of Content
1 Prerequisites
Before installing Laravel 13, ensure you have the following prerequisites installed on your system:
1. PHP ≥ 8.3Laravel 13 requires PHP version 8.3 or higher (supports up to PHP 8.5).
Check with:
php -v
If PHP is not installed, install it using Homebrew (macOS), apt/yum (Linux), or use tools like XAMPP, Laragon, Laravel Herd, or WampServer on Windows.
Laravel uses Composer to manage its dependencies.
Check Composer:
composer -v
Install Composer: https://getcomposer.org/download/
You can use MySQL, PostgreSQL, SQLite, etc.
For development, SQLite is now the default, but MySQL remains the most commonly used in production.
5. Web Server: Apache or Nginx is recommended (or use Laravel Herd for local development).
2 Introduction
3 What's New in Laravel 13?
Laravel 13 introduces the official Laravel AI SDK, providing a unified API for text generation, tool-calling agents, embeddings, audio, images, and vector-store integrations. Build provider-agnostic AI features with a consistent, Laravel-native developer experience.
use App\Ai\Agents\SalesCoach;
$response = SalesCoach::make()->prompt('Analyze this sales transcript...');
return (string) $response;
2. PHP Attributes for Configuration PHP 8 Attributes replace the need for class properties like $table, $hidden, $fillable, and more on your models. This also applies to listeners, notifications, mailables, and broadcast events.
#[Table('users', key: 'user_id', keyType: 'string', incrementing: false)]
class User extends Model
{
// No need for $table, $primaryKey properties
}
3. JSON:API Resources - First-party JSON:API resources handle resource object serialization, relationship inclusion, sparse fieldsets, links, and compliant response headers automatically.
- Passkey support is now integrated into the official starter kits and underlying Laravel Fortify, enabling passwordless authentication out of the box.
- Build AI-powered semantic search using PostgreSQL + pgvector directly from the query builder:
$documents = DB::table('documents')
->whereVectorSimilarTo('embedding', 'Best wineries in Napa Valley')
->limit(10)
->get();
6. Queue Routing by Class - New Queue::route() method lets you define default queue/connection routing rules for job classes from a single location in a service provider.
- The new starter kits bring team-based multi-tenancy back with URL-based routing. You can operate two different team contexts in separate browser tabs.
- New PreventRequestForgery middleware adds origin-aware request verification while preserving compatibility with token-based CSRF protection.
- Laravel 13 drops support for PHP 8.2, requiring PHP 8.3 or higher. This unlocks typed class constants, json_validate(), JIT optimizations, and the #[Override] attribute.
- Cleaner scaffolding with Symfony 7.4/8.0 components
- More expressive code generation
- Removed legacy polyfills and backward-compatibility layers
- Better error messages and helpful Artisan commands
4 Create / Install a Laravel Project
4.1 Install Laravel Using Composer
macOS:
/bin/bash -c "$(curl -fsSL https://php.new/install/mac/8.4)"
Windows (Run as Administrator):
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://php.new/install/windows/8.4'))
Linux:
/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
Then create a new Laravel project:
laravel new my-laravel-app
The installer will prompt you to select your preferred testing framework, database, and starter kit.
composer create-project laravel/laravel:^13.0 my-laravel-app
cd my-laravel-app
chmod -R 775 storage bootstrap/cache
cp .env.example .env
php artisan key:generate
4.2 Configure MySql Database
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel13
DB_USERNAME=root
DB_PASSWORD=
Make sure the database exists before running migrations. Note: Laravel 13 uses SQLite as the default database. To use MySQL, update the DB_CONNECTION value in your .env file.
php artisan migrate
5 Folder Structure
Holds the core application code:
- Console/ - Artisan commands
- Exceptions/ - Custom exception handling
- Http/ - Controllers, middleware, requests
- Models/ - Eloquent models
- Providers/ - Service providers
This is where most of your custom logic lives.
Contains the app.php file which bootstraps the framework. The cache/ folder stores compiled files for faster loading.
All your configuration files — database, queue, mail, app, etc. Each aspect of Laravel is configurable here.
Organized into:
- migrations/ - Schema definition files
- factories/ - Model factories for testing and seeding
- seeders/ - Seed classes to populate your database
The web server points here. It contains the index.php front controller and assets like images, CSS, and JavaScript.
Where your frontend lives:
- views/ - Blade templates
- css/, js/ - Frontend assets (with Vite)
- lang/ - Optional language files
- markdown/ - If using markdown-based notifications
Contains all your route definitions:
- web.php - Routes for web (session/cookie)
- api.php - Stateless API routes
- console.php - Artisan commands
- channels.php - Broadcast channel routes
Used for file storage:
- app/ - Local files
- framework/ - Cached views, sessions, etc.
- logs/ - Application logs
Composer-managed dependencies. You don't edit this — it's managed automatically.
- artisan - CLI tool for managing Laravel
- composer.json - PHP dependency list
- package.json - JS dependencies (for Vite)
6 Run Laravel Server to Test the App
php artisan serve
Or use the dev Composer script to start the development server, queue worker, and Vite simultaneously:
composer run dev
Your application will be available at http://localhost:8000
7 Conclusion
Written by Revathi M
PHP Developer & Technical Writer · 10+ years building web applications with CodeIgniter and Laravel
Revathi specializes in PHP backend development, authentication systems, and REST API design. She writes practical, production-tested tutorials at Get Sample Code to help developers build secure applications faster.
Frequently Asked Questions
Laravel 13 requires PHP 8.3 or higher (supports up to PHP 8.5). Check your version with 'php -v'.
Run 'composer create-project laravel/laravel:^13.0 my-laravel-app' to create a new project. Alternatively, use the Laravel installer with 'laravel new my-laravel-app'.
You need PHP ≥ 8.3, Composer installed, an optional database like MySQL or SQLite, Node.js and npm for frontend assets, and a web server like Apache or Nginx (or Laravel Herd for local development).
Copy '.env.example' to '.env' using 'cp .env.example .env', then update database credentials and other settings.
Run 'php artisan key:generate' after setting up the .env file.
Edit the .env file with DB_CONNECTION=mysql, DB_HOST=127.0.0.1, DB_PORT=3306, DB_DATABASE=your_database, DB_USERNAME, and DB_PASSWORD. Note that SQLite is the default database in Laravel 13.
After configuring the database, run 'php artisan migrate' to create the default tables.
Run 'php artisan serve' from the project directory to start the server at http://localhost:8000. You can also use 'composer run dev' to start the server, queue worker, and Vite simultaneously.
Laravel 13 includes the first-party AI SDK for text generation and agents, PHP Attributes for model configuration, JSON:API resources, passkey authentication, native vector search support, queue routing by class, and team-based multi-tenancy in starter kits.
No, Laravel 13 has zero breaking changes from Laravel 12. The upgrade is straightforward and estimated at about 10 minutes for most applications. You can also use Laravel Shift for automated upgrades.
