1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravelでローカルでsqliteを利用してDBの環境構築

Last updated at Posted at 2024-03-01

laravelでローカルでsqliteを利用してDBの環境構築する方法をいつも忘れてしまうのでやり方をメモします。

まずconfigディレクトリのdatabase.phpの一部を次のように修正します。

database.php
<?php

use Illuminate\Support\Str;

return [

    /*
    |--------------------------------------------------------------------------
    | Default Database Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the database connections below you wish
    | to use as your default connection for all database work. Of course
    | you may use many connections at once using the Database library.
    |
    */
-  'default' => env('DB_CONNECTION', 'mysql'),
+  'default' => env('DB_CONNECTION', 'sqlite'),

    //以下省略

続いて、.envファイルを以下のように修正します

.env
+ DB_CONNECTION=sqlite
-  DB_HOST=*****
-  DB_PORT=***
-  DB_DATABASE=***
-  DB_USERNAME=****
-  DB_PASSWORD=****

最後に、database.sqliteをdatabaseディレクトリ直下に作成します。
sqlite2.png

以上で完了です。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?