2

I want to use SQLITE for my laravel5 project on my webserver. I migrated my local laravel 5 project onto my AWS ec2 lamp Ubuntu server. http://realtoraxe.com/realtoraxe/public/ but it shows

InvalidArgumentException in SQLiteConnector.php line 34: Database does not exist.

I changed the database.php set for sqlite

 <?php
 return array(
    'default' => 'sqlite',
    'connections' => array(
    'sqlite' => array(
    'driver'   => 'sqlite',
    'database' =>    'http://realtoraxe.com/realtoraxe/storage/database.sqlite',
    'prefix'   => '',
     ),
   ),
  );
 ?>

and I changed the .env to

APP_ENV=local
APP_DEBUG=true
APP_KEY=mystring
DB_CONNECTION=sqlite
CACHE_DRIVER=file
SESSION_DRIVER=file

when I do php artisan migrate it says there is no database

I think what I wrote as the path for the database in the database.php is wrong and do I may need to somehow write where my ip adress is in the .env file? I have been googling all night and can't seem to figure this out.

1
  • There are default sqlite config options in database.php. Because it already expects the file to be in your storage folder and named database.sqlite, the only thing you have to do is add DB_CONNECTION=sqlite to your .env file. Commented Apr 1, 2016 at 16:14

3 Answers 3

9

You dont need to edit the .php files at all. You can all do it in the .env file, since the files in the config directory are written to first use the values from the .env file, and if they are not defined, fall back on what is defined there.

env('DB_CONNECTION','mysql') would yield the value from the .env file, and only if it is not defined fall back to mysql.

So in your .env file just put the following:

DB_CONNECTION=sqlite DB_DATABASE=database/database.sqlite and create a file called database.sqlite in your database directory (thats where its supposed to be by convention.). That's it.

Sign up to request clarification or add additional context in comments.

Comments

5

For default laravel 5.2+ installation:

create an sqlite database file

$ cd storage
$ touch database.sqlite
$ cd ..

make it writeable

$ chmod -R 777 storage

at ".env" file:

DB_CONNECTION=sqlite
DB_DATABASE=storage/database.sqlite

and remove or comment all other DB_* records

If you prefer to use relative path, instead of absolute to database file at "config/database.php"

instead of:

'database' => env('DB_DATABASE', database_path('database.sqlite')),

write:

'database' => __DIR__ . '/../' . env( 'DB_DATABASE' ),

now, laravel app will be able to find sqlite file, and php artisan will work too

2 Comments

Any reason to store it in the storage directory instead of the database directory?
FYI: Actually that changed in Laravel 9. It is now saved in database. @kjones
2

Why are you using HTTP link? I guess it should link to a .sqlite DB file:

'database' => __DIR__.'/../database/production.sqlite',

http://laravel-recipes.com/recipes/118/setting-up-the-sqlite-database-driver

3 Comments

yeah. thats an http link. Do i need to add anything else to my .env file?
@user432495, so did you understand that you can't use HTTP link? You should give a link to the concrete file.
yeah. The file is in the /database/database.sqlite. I wrote the line as 'database' => DIR.'/../database/database.sqlite', (It still doesn't see it)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.