Table of contents

laravel sqlite

In this post, I will share how to use SQLite Database in Laravel 8, and 9. If your project is light and not a huge database then SQLite is suitable to use. It is an option also to use SQLite while developing locally. Now I will show you an example. Just follow my few steps below on how to implement the Laravel SQLite database.


First, Install Laravel 9.

Point to your htdocs directory and open your command prompt. Then run the following command:

composer create-project laravel/laravel laravel-sqlite


Once installed run the next command to your command prompt.

cd laravel-sqlite


Second, Setup ENV for our SQLite Database

By default, you will see these lines inside the .env file.



Now, let's change it with the following lines below.



As you can see we changed the DB_CONNECTION value to SQLite and removed DB_DATABASE, DB_USERNAME, and DB_PASSWORD.


Third, Create Laravel SQLite Database

Now lets, create our database inside your Laravel 9 directory project and navigate to the following path: project_folder/database then create a file named database.sqlite.


laravel sqlite


Fourth, Run Migration Command

Now, let's run the migration command.

php artisan migrate


Once done your Laravel SQLite database is ready.


Now let's check application is working and if successfully connected with the SQLite database.


See below code from routes/web.php.


use App\Models\User;
use Illuminate\Support\Facades\Route;

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!

Route::get('/', function () {

        'email' => ''
        'name' => 'John Doe',
        'email' => '',
        'password' => bcrypt('password')

    $users = User::all();



Then run the command:

php artisan serve


Then run this to your browser:


laravel sqlite

That's it you have successfully installed Laravel SQLite to your local server on windows. I hope it helps.


Cheers :)