Turso + Laravel
Set up Turso in your Laravel project in minutes
Prerequisites
Before you start, make sure you:
- Install the Turso CLI
- Sign up or login to Turso
- Have an Laravel Application
Download the latest build extension/driver binary you can see at Release page. It's available for:
- Linux
- Mac/Darwin
- Windows (WSL) / Devcontainer
Now, LibSQL
class is available in your PHP environment! You can use it everywhere in your PHP project 🎉
Configure database credentials
Get the database URL:
Get the database authentication token:
Assign credentials to the environment variables inside .env
.
Create Laravel Project
Using Composer:
If you already have laravel installer:
Install Turso Driver Laravel
Install turso-driver-laravel
:
Add this LibSQLServiceProvider
class at bootstrap/providers.php
:
Configure database connection
Setup the environment variable in your Laravel application, choose what the type connection you need.
Other environment variables (Embedded Replica Only)
Database configuration
Add this configuration at config/database.php
inside the connections
array:
Create database seeders
In fresh Laravel installation, your can open file database/seeders/DatabaseSeeder.php
and change the code with this:
then create the database seeders:
Execute Query
Examples
Was this page helpful?