The First Things You Should Do When You Start a New Laravel Project

Starting a new Laravel project always feels great, a blank canvas, clean code, and the freedom to build things the right way this time. But that early excitement can quickly fade if you skip the groundwork. The decisions you make at the very beginning often decide whether your app stays maintainable or turns into a mess a few months down the road.
In this guide, we’ll go through the essential steps to set up a strong foundation for your Laravel project — from architecture and security to tooling, automation, and documentation — so you can build fast without creating future pain.
Let's dive deeper👇
1. Create the Project and Configure the Environment
Start clean:
laravel new project-name
or
composer create-project laravel/laravel project-name
Then immediately configure your .env
file:
APP_NAME="My Awesome App"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://myapp.test
And secure your app key:
php artisan key:generate
This ensures that encryption, sessions, and cookies work properly from the start.
Then, initialize the Git repository of your application:
git init
git add .
git commit -m "Initial commit: fresh Laravel install"
And then push your repository to your git remote (or you can do that later).
git push origin/main
2. Decide: User-Based or Tenant-Based Architecture
Before writing a single line of code, decide whether your app will be user-based (single-tenant) or tenant-based (multi-tenant).
User-Based (Single Tenant)
In this setup, all users share the same database and application logic, making it ideal for tools that operate within a shared environment, like B2C application, where you only expect your application to be used by 1 person (not a company or a team).
The standard Laravel setup fits perfectly for this type of architecture, keeping things simple and efficient without the extra complexity of multi-tenancy.
Tenant-Based (Multi Tenant)
In a tenant-based (multi-tenant) setup, each customer — or tenant — has fully isolated data, either through separate databases or schemas. This architecture is essential for SaaS platforms that serve independent organizations or B2B applications, where your customer is basically a company (or a team that needs access to some shared data), ensuring that each tenant’s data and configuration remain completely separate and secure.
For that you can use established tenancy libraries:
- stancl/tenancy - for database or domain-based tenancy
- spatie/laravel-multitenancy - another good but simple multi-tenancy package.
- SaaSykit Tenancy - a full SaaS starter kit that comes with solid multi-tenancy features like team managements, seat-based billing, tenancy dashboards and much more.
Defining this early prevents painful migrations later, tenancy touches authentication, billing, storage, and routing.
3. Choose Your Database Engine
Choosing the right database is a key decision that impacts scalability, indexing, and how you handle JSON data.
MySQL or MariaDB are excellent default choices, offering broad support, mature tools, and solid performance for most applications.
PostgreSQL stands out if you need advanced JSON handling with JSONB, complex constraints, or full-text search capabilities.
SQLite, on the other hand, is lightweight and ideal for testing, prototyping, or small-scale projects where simplicity matters most.
4. Set Up an AGENTS.md File
Creating an AGENTS.md
file at the start of your project is a great way to document its structure, purpose, and coding standards, especially if you plan to leverage AI agents (Claude, Codex, etc) for development or code generation.
This file should describe your project, outline its architecture, and list all the conventions and rules that AI tools should follow when interacting with your code.
By clearly defining these guidelines, you ensure that AI-assisted coding aligns with your expectations and maintains consistency across the project.
Tools like the Laravel Boost library can help streamline the creation of this file and make it easier to integrate AI agents effectively.
5. Set Up Local Development Tools
Making your local development environment as close as possible to production helps prevent headaches down the line — no more “works on my machine” surprises.
-
Laravel Sail provides a Dockerized environment that mirrors production, ensuring consistency across all machines and making it easy to manage dependencies.
-
Laravel Herd offers fast, lightweight native setups for macOS or Windows, letting you run Laravel projects without the overhead of full Docker containers.
-
Laravel Telescope gives deep insight into your application’s behavior, including queries, requests, exceptions, and performance metrics, helping you catch issues early.
Using these tools from the start keeps your workflow smooth, reduces bugs, and gives you a better understanding of how your app behaves under real conditions.
6. Install Essential Development Packages
Install foundational packages that improve your workflow:
-
barryvdh/laravel-debugbar
– Adds a developer toolbar to your app with detailed information about queries, requests, and performance. -
barryvdh/laravel-ide-helper
– Generates helper files to improve IDE auto-completion and make your development smoother. -
nunomaduro/larastan
– A static analysis tool that catches errors and enforces code quality before runtime. -
laravel/pint
– A zero-configuration code style fixer for Laravel projects, ensuring consistent, clean, and readable code across your team.
Run the following:
composer require --dev barryvdh/laravel-debugbar
composer require --dev barryvdh/laravel-ide-helper
composer require --dev nunomaduro/larastan
composer require --dev laravel/pint
These tools improve your development flow, catch hidden bugs, and enforce consistent standards.
7. Configure Static Analysis and Type Safety
Add a phpstan.neon.dist
file for Larastan:
includes:
- vendor/nunomaduro/larastan/extension.neon
parameters:
level: 8
paths:
- app
checkMissingIterableValueType: true
checkMissingVarReturn: true
reportUnmatchedIgnoredErrors: true
The run:
php artisan code:analyse
This ensures type correctness, undefined property checks, and more. Static analysis is your first line of defense against subtle logic errors.
8. Enforce Strict Models
One of the first things to do when you start a new application is enable strict model behavior.
In the AppServiceProvider
, I go to the boot
method and set Model::shouldBeStrict()
.
public function boot(): void
{
Model::shouldBeStrict();
}
This simple line ensures your models are strict from the start: it prevents lazy loading, stops attributes from being silently discarded, and throws errors when you try to access missing attributes. Enabling this early helps catch potential bugs before they grow into bigger problems and encourages more deliberate, predictable interactions with your models.
9. Set Up Testing Early
Testing shouldn’t be an afterthought — it’s a crucial part of building reliable applications. Start by deciding which testing framework fits your workflow: Pest for elegant, readable tests, or PHPUnit if you prefer the classic approach.
Add a simple smoke test to get started: