- Install the Turso Laravel adapter
- Configure Laravel to use Turso
- Create a model and migration
- Perform CRUD operations using Eloquent
1
Retrieve database credentials
You will need an existing database to continue. If you don’t have one, create one.Get the database URL:Get the database authentication token:Assign credentials to the environment variables inside
.env
.You will want to store these as environment variables.
2
Install
Install the package to your Laravel project using Composer:
Make sure to enable FFI in your PHP configuration to use the Laravel adapter.
3
Configure
Choose your preferred setup and configure accordingly:
Local only
Local only
Update your This will use a local SQLite file with the libSQL adapter.
config/database.php
:Remote only
Remote only
Update your Then add to your
config/database.php
:.env
file:Embedded Replicas
Embedded Replicas
Update your Then add to your
config/database.php
:.env
file:The
sync_interval
is optional and defaults to 300 seconds (5 minutes).4
Create a model and migration
Create a User model and migration:Update the migration file:
5
Run migrations
Apply the migration to create the users table:
6
Execute CRUD operations
Now you can perform CRUD operations using Eloquent: