The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
---
title: 'Use Supabase with Laravel'
subtitle: 'Learn how to create a PHP Laravel project, connect it to your Supabase Postgres database, and configure user authentication.'
breadcrumb: 'Framework Quickstarts'
---
<AiPrompt id="laravel" />
<$Partial path="quickstart_create_project.mdx" />
Save your database password securely. You need it for the connection string.
<Admonition type="note">
This guide uses Laravel's own database tables (via Breeze and Eloquent), not the shared `instruments` sample table used by other quickstarts.
</Admonition>
## 2. Create a Laravel project
Make sure your PHP and Composer versions are up to date, then use `composer create-project` to scaffold a new Laravel project.
See the [Laravel docs](https://laravel.com/docs/12.x/installation#creating-a-laravel-project) for more details.
```bash
composer create-project laravel/laravel example-app
```
## 3. Set up AI tooling (optional)
<$Partial path="quickstart_ai_tooling.mdx" />
## 4. Install the authentication template
Install [Laravel Breeze](https://github.com/laravel/breeze), a basic implementation of all of Laravel's [authentication features](https://laravel.com/docs/12.x/authentication). It ships the migrations that the next step runs against your Supabase database.
```bash
composer require laravel/breeze --dev
php artisan breeze:install blade
```
Pass a stack name such as `blade`, `react`, or `vue` when prompted. The example above uses Blade templates.
## 5. Set up the Postgres connection details
<$Partial path="quickstart_connection_string.mdx" />
```bash name=.env
DB_CONNECTION=pgsql
DB_URL=postgres://postgres.[PROJECT-REF]:[YOUR-PASSWORD]@[POOLER-HOST]:5432/postgres
```
Laravel sets `sslmode` as an explicit `config/database.php` option rather than a URL parameter. The next step covers this.
## 6. Change the default schema
By default Laravel uses the `public` schema. We recommend changing this as Supabase exposes the `public` schema as a [data API](/docs/guides/api).
You can change the schema of your Laravel application by modifying the `search_path` variable in `config/database.php`.
The schema you specify in `search_path` has to exist on Supabase. You can create a new schema from the [Table Editor](/dashboard/project/_/editor).
```php name=config/database.php
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DB_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'laravel'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'charset' => env('DB_CHARSET', 'utf8'),
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'laravel',
'sslmode' => 'require',
],
```
Laravel ships with `sslmode` set to `prefer`, which sends your data in plaintext if the encrypted attempt fails. Set it to `require` so the connection fails instead. You can also [enforce SSL](/docs/guides/platform/ssl-enforcement) on the database side.
## 7. Run the database migrations
Laravel ships with database migration files that set up the required tables for Laravel Authentication and User Management.
<Admonition type="note">
Laravel implements its own authentication system rather than using Supabase Auth. Your users are stored in Laravel's `users` table, not in Supabase Auth.
</Admonition>
```bash
php artisan migrate
```
## 8. Start the app
Run the development server. Go to http://127.0.0.1:8000 in a browser to see your application. You can also navigate to http://127.0.0.1:8000/register and http://127.0.0.1:8000/login to register and sign in users.
```bash
php artisan serve
```
<$Partial path="quickstart_going_to_production.mdx" />
## Next steps
- Learn more about [Supabase Auth](/docs/guides/auth) if you want to replace Laravel's built-in authentication
- [Insert more data](/docs/guides/database/import-data) into your database
- Upload and serve static files using [Storage](/docs/guides/storage)