How to use supabase with laravel?

Deploying application a lot easier these days, one of the most important component of our Laravel application is database. While managing database is not an easy task there are a lot of company that offer managed database that can help us to save time configuring database. Today we will learn how to use managed database service Supabase with laravel application.

Create Supabase account

Supabase is managed database service powered by PostgreSQL database, supabase offer a lot of feature like row level permission, vector embedding with pgvector and a lot more.

But today we only care about the database, so we are not going to use any of supbase features. To create supabase account is very easy.

You can go to, there are two options register with email and password or with your github account.


Get supabase credentials

After signup now let's create new project, new project means new database. To create new project you can click button new project.


After click new project you will see these form. You can fill the form and make sure to save the database password, we need this to manually connect to our database later.


Finally you can grab the credentials of your database from Setting > Database page.


New laravel project

You can use this in your existing laravel project or new laravel project, if you want to create new project follow this step.

Run laravel new to create project:

laravel new supabase-laravel-example


Don't forget to select postgres database drived.


And now we can just put that credentials to our .env file. Here's example config.


Verify setup

The last thing you need to do is to verify your database config by running the migration.

php artisan migrate

If the migration works then you good to go now.