dev-resources.site
for different kinds of informations.
Day 5: Use Supabase with Laravel
Published at
1/1/2025
Categories
laravel
php
beginners
tutorial
Author
Ehtesham Ali
Learn how to connect a Laravel project to a Supabase Postgres database and configure user authentication seamlessly.
1. Create a Laravel Project
Ensure PHP and Composer are up to date, then scaffold your Laravel project:
composer create-project laravel/laravel example-app
2. Install Authentication Template
Set up Laravel Breeze for user authentication:
composer require laravel/breeze --dev
php artisan breeze:install
3. Configure Postgres Connection
- Create a new Supabase project at database.new. Note if account not created will display:
Other wise will display this:
- Copy the URI connection string.
Note to get connection string click on connect button:
- Replace password with your database password. Update .env:
DB_CONNECTION=pgsql
DATABASE_URL=postgres://postgres.xxxx:[email protected]:5432/postgres
4. Change Default Schema
Modify search_path in app/config/database.php to avoid using the public schema (default for Supabase's API):
'pgsql' => [
'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => 'laravel',
'sslmode' => 'prefer',
],
5. Run Migrations
Set up the required authentication tables:
php artisan migrate
6. Start the App
Run the development server and test user registration and login:
php artisan serve
Access your app at http://127.0.0.1:8000.
That's it! Your Laravel app is now connected to Supabase, ready for development.
Articles
12 articles in total
Pro Laravel Developer
read article
Reflecting on 2024: From CodeIgniter to Laravel and Building Integrated Solutions
read article
Day 6: Building APIs with Laravel Sanctum
read article
Day 5: Use Supabase with Laravel
currently reading
Module 1: Introduction to Amazon Web Services
read article
Day 4: Configuring Laravel: Environment Setup
read article
Day 0 - How to Become AWS Cloud Practitioner: Overview
read article
Day 3: Exploring Laravelโs Directory Structure
read article
Day 2 : Host Static App on GitHub Pages
read article
Day 1: Setup Laravel
read article
Day 0: Laravel
read article
Integrating TikTok API with Laravel: A Comprehensive Guide
read article
Featured ones: